diff --git a/doc/manual/matlab.rst b/doc/manual/matlab.rst index 6668cb02dcd..d505fb5e5a8 100644 --- a/doc/manual/matlab.rst +++ b/doc/manual/matlab.rst @@ -696,7 +696,7 @@ The documented structures are: | FIFFV_PROJ_ITEM_HOMOG_FIELD | 5 | This projection item contains the three homogeneous field| | | | components as seen by the sensor array. | +-------------------------------+-------+----------------------------------------------------------+ - | FIFFV_MNE_PROJ_ITEM_EEG_AVREF | 10 | This projection item corresponds to the average EEG | + | FIFFV_PROJ_ITEM_EEG_AVREF | 10 | This projection item corresponds to the average EEG | | | | reference. | +-------------------------------+-------+----------------------------------------------------------+ diff --git a/mne/io/constants.py b/mne/io/constants.py index ba6390bfa03..ebbf1c1f09a 100644 --- a/mne/io/constants.py +++ b/mne/io/constants.py @@ -290,7 +290,9 @@ def __setattr__(self, attr, val): # noqa: D105 # BEM surface IDs # FIFF.FIFFV_BEM_SURF_ID_UNKNOWN = -1 +FIFF.FIFFV_BEM_SURF_ID_NOT_KNOWN = 0 FIFF.FIFFV_BEM_SURF_ID_BRAIN = 1 +FIFF.FIFFV_BEM_SURF_ID_CSF = 2 FIFF.FIFFV_BEM_SURF_ID_SKULL = 3 FIFF.FIFFV_BEM_SURF_ID_HEAD = 4 @@ -327,6 +329,7 @@ def __setattr__(self, attr, val): # noqa: D105 FIFF.FIFFV_POINT_EEG = 3 FIFF.FIFFV_POINT_ECG = FIFF.FIFFV_POINT_EEG FIFF.FIFFV_POINT_EXTRA = 4 +FIFF.FIFFV_POINT_HEAD = 5 # Point on the surface of the head FIFF.FIFFV_POINT_LPA = 1 FIFF.FIFFV_POINT_NASION = 2 @@ -584,7 +587,6 @@ def __setattr__(self, attr, val): # noqa: D105 FIFF.FIFFV_MNE_DEPTH_PRIOR_COV = 5 # The depth weighting prior FIFF.FIFFV_MNE_ORIENT_PRIOR_COV = 6 # The orientation prior -FIFF.FIFFV_MNE_PROJ_ITEM_EEG_AVREF = 10 # Linear projection related to EEG average reference # # Output map types # @@ -623,6 +625,30 @@ def __setattr__(self, attr, val): # noqa: D105 FIFF.FIFFV_PROJ_ITEM_DIP_ROT = 3 FIFF.FIFFV_PROJ_ITEM_HOMOG_GRAD = 4 FIFF.FIFFV_PROJ_ITEM_HOMOG_FIELD = 5 +FIFF.FIFFV_PROJ_ITEM_EEG_AVREF = 10 # Linear projection related to EEG average reference +FIFF.FIFFV_MNE_PROJ_ITEM_EEG_AVREF = FIFF.FIFFV_PROJ_ITEM_EEG_AVREF # backward compat alias +# +# SSS job options +# +FIFF.FIFFV_SSS_JOB_NOTHING = 0 # No SSS, just copy input to output +FIFF.FIFFV_SSS_JOB_CTC = 1 # No SSS, only cross-talk correction +FIFF.FIFFV_SSS_JOB_FILTER = 2 # Spatial maxwell filtering +FIFF.FIFFV_SSS_JOB_VIRT = 3 # Transform data to another sensor array +FIFF.FIFFV_SSS_JOB_HEAD_POS = 4 # Estimate head positions, no SSS +FIFF.FIFFV_SSS_JOB_MOVEC_FIT = 5 # Estimate and compensate head movement +FIFF.FIFFV_SSS_JOB_MOVEC_QUA = 6 # Compensate head movement from previously estimated head positions +FIFF.FIFFV_SSS_JOB_REC_ALL = 7 # Reconstruct inside and outside signals +FIFF.FIFFV_SSS_JOB_REC_IN = 8 # Reconstruct inside signals +FIFF.FIFFV_SSS_JOB_REC_OUT = 9 # Reconstruct outside signals +FIFF.FIFFV_SSS_JOB_ST = 10 # Spatio-temporal maxwell filtering +FIFF.FIFFV_SSS_JOB_TPROJ = 11 # Temporal projection, no SSS +FIFF.FIFFV_SSS_JOB_XSSS = 12 # Cross-validation SSS +FIFF.FIFFV_SSS_JOB_XSUB = 13 # Cross-validation subtraction, no SSS +FIFF.FIFFV_SSS_JOB_XWAV = 14 # Cross-validation noise waveforms +FIFF.FIFFV_SSS_JOB_NCOV = 15 # Noise covariance estimation +FIFF.FIFFV_SSS_JOB_SCOV = 16 # SSS sample covariance estimation +#} + # # Additional coordinate frames # @@ -707,6 +733,7 @@ def __setattr__(self, attr, val): # noqa: D105 # # SI base units # +FIFF.FIFF_UNIT_UNITLESS = 0 FIFF.FIFF_UNIT_M = 1 # meter FIFF.FIFF_UNIT_KG = 2 # kilogram FIFF.FIFF_UNIT_SEC = 3 # second @@ -725,6 +752,7 @@ def __setattr__(self, attr, val): # noqa: D105 # # SI derived units # +FIFF.FIFF_UNIT_MOL_M3 = 10 # mol/m^3 FIFF.FIFF_UNIT_HZ = 101 # hertz FIFF.FIFF_UNIT_N = 102 # Newton FIFF.FIFF_UNIT_PA = 103 # pascal @@ -754,6 +782,7 @@ def __setattr__(self, attr, val): # noqa: D105 FIFF.FIFF_UNITM_E = 18 FIFF.FIFF_UNITM_PET = 15 FIFF.FIFF_UNITM_T = 12 +FIFF.FIFF_UNITM_GIG = 9 FIFF.FIFF_UNITM_MEG = 6 FIFF.FIFF_UNITM_K = 3 FIFF.FIFF_UNITM_H = 2 diff --git a/mne/io/proj.py b/mne/io/proj.py index d64bd05098d..3cee1dcfaa9 100644 --- a/mne/io/proj.py +++ b/mne/io/proj.py @@ -611,7 +611,7 @@ def _make_projector(projs, ch_names, bads=(), include_active=True, orig_n = p['data']['data'].any(axis=0).sum() # Average ref still works if channels are removed if len(vecsel) < 0.9 * orig_n and not inplace and \ - (p['kind'] != FIFF.FIFFV_MNE_PROJ_ITEM_EEG_AVREF or + (p['kind'] != FIFF.FIFFV_PROJ_ITEM_EEG_AVREF or len(vecsel) == 1): warn('Projection vector "%s" has magnitude %0.2f ' '(should be unity), applying projector with ' @@ -794,7 +794,7 @@ def make_eeg_average_ref_proj(info, activate=True, verbose=None): data=vec, nrow=1, ncol=n_eeg) eeg_proj = Projection(active=activate, data=eeg_proj_data, desc='Average EEG reference', - kind=FIFF.FIFFV_MNE_PROJ_ITEM_EEG_AVREF, + kind=FIFF.FIFFV_PROJ_ITEM_EEG_AVREF, explained_var=explained_var) return eeg_proj @@ -807,7 +807,7 @@ def _has_eeg_average_ref_proj(projs, check_active=False): """ for proj in projs: if (proj['desc'] == 'Average EEG reference' or - proj['kind'] == FIFF.FIFFV_MNE_PROJ_ITEM_EEG_AVREF): + proj['kind'] == FIFF.FIFFV_PROJ_ITEM_EEG_AVREF): if not check_active or proj['active']: return True return False diff --git a/mne/io/reference.py b/mne/io/reference.py index 4cf8e5a9983..0876e35759f 100644 --- a/mne/io/reference.py +++ b/mne/io/reference.py @@ -103,7 +103,7 @@ def _apply_reference(inst, ref_from, ref_to=None): for i, proj in enumerate(inst.info['projs']): # Remove any average reference projections if proj['desc'] == 'Average EEG reference' or \ - proj['kind'] == FIFF.FIFFV_MNE_PROJ_ITEM_EEG_AVREF: + proj['kind'] == FIFF.FIFFV_PROJ_ITEM_EEG_AVREF: logger.info('Removing existing average EEG reference ' 'projection.') # Don't remove the projection right away, but do this at the end of diff --git a/mne/io/tests/test_constants.py b/mne/io/tests/test_constants.py index 32929e70763..f60e563f2f0 100644 --- a/mne/io/tests/test_constants.py +++ b/mne/io/tests/test_constants.py @@ -23,6 +23,13 @@ 'has_key', 'iteritems', 'iterkeys', 'itervalues', # Py2 'viewitems', 'viewkeys', 'viewvalues', # Py2 ) +_ignore_incomplete_enums = ( # XXX eventually we could complete these + 'bem_surf_id', 'cardinal_point_cardiac', 'cond_model', 'coord', + 'dacq_system', 'diffusion_param', 'gantry_type', 'map_surf', + 'mne_lin_proj', 'mne_ori', 'mri_format', 'mri_pixel', 'proj_by', + 'tags', 'type', 'iod', 'volume_type', 'vol_type', + 'coil', # Especially these! 3015, 3025 +) # not in coil_def.dat but in DictionaryTypes:enum(coil) _missing_coil_def = ( 0, # The location info contains no data @@ -207,6 +214,7 @@ def test_constants(tmpdir): unknowns = list() # Assert that all our constants are in the FIF def + assert 'FIFFV_SSS_JOB_NOTHING' in dir(FIFF) for name in sorted(dir(FIFF)): if name.startswith('_') or name in _dir_ignore_names: continue @@ -245,6 +253,8 @@ def test_constants(tmpdir): else: raise RuntimeError('Could not find %s' % (name,)) assert check in used_enums, name + if 'SSS' in check: + raise RuntimeError elif name.startswith('FIFF_UNIT'): # units and multipliers check = name.split('_')[1].lower() elif name.startswith('FIFF_'): @@ -262,13 +272,17 @@ def test_constants(tmpdir): assert len(unknowns) == 0, 'Unknown types\n\t%s' % unknowns # Assert that all the FIF defs are in our constants + assert set(fif.keys()) == set(con.keys()) for key in sorted(set(fif.keys()) - set(['defines'])): this_fif, this_con = fif[key], con[key] assert len(set(this_fif.keys())) == len(this_fif) assert len(set(this_con.keys())) == len(this_con) - assert set(con.keys()) - set(fif.keys()) == set() - missing = sorted(set(fif.keys()) - set(con.keys())) - assert missing == [], key + missing_from_con = sorted(set(this_con.keys()) - set(this_fif.keys())) + assert missing_from_con == [], key + if key not in _ignore_incomplete_enums: + missing_from_fif = sorted(set(this_fif.keys()) - + set(this_con.keys())) + assert missing_from_fif == [], key # Assert that `coil_def.dat` has accurate descriptions of all enum(coil) coil_def = _read_coil_defs() diff --git a/mne/preprocessing/maxwell.py b/mne/preprocessing/maxwell.py index ac3a47b5ad1..306493f9b66 100644 --- a/mne/preprocessing/maxwell.py +++ b/mne/preprocessing/maxwell.py @@ -410,7 +410,11 @@ def maxwell_filter(raw, origin='auto', int_order=8, ext_order=3, # Reconstruct raw file object with spatiotemporal processed data max_st = dict() if st_duration is not None: - max_st.update(job=10, subspcorr=st_correlation, + if st_only: + job = FIFF.FIFFV_SSS_JOB_TPROJ + else: + job = FIFF.FIFFV_SSS_JOB_ST + max_st.update(job=job, subspcorr=st_correlation, buflen=st_duration / info['sfreq']) logger.info(' Processing data using tSSS with st_duration=%s' % max_st['buflen']) @@ -1464,7 +1468,8 @@ def _update_sss_info(raw, origin, int_order, ext_order, nchan, coord_frame, components[reg_moments] = 1 sss_info_dict = dict(in_order=int_order, out_order=ext_order, nchan=nchan, origin=origin.astype('float32'), - job=np.array([2]), nfree=np.sum(components[:n_in]), + job=FIFF.FIFFV_SSS_JOB_FILTER, + nfree=np.sum(components[:n_in]), frame=_str_to_frame[coord_frame], components=components) max_info_dict = dict(max_st=max_st)