If you have a question or issue with MNE-Python, please include the following info:
- MNE version: 1.10.0
- operating system: e.g. macOS Sequoia 15.7.2.
Please also provide relevant code snippets – ideally a minimal working example (MWE).
After succesfully producing power and itc using the “compute_tfr” function as follows:
epos = mne.read_epochs(epo_in, preload=True)
epos.pick(picks)
epos.drop_bad(reject = reject_epo)
epos = mne.epochs.combine_event_ids(epos,
[‘ref/-8_proj’,
‘ref/-4_proj’,
‘ref/4_proj’,
‘ref/8_proj’],
{‘ref/comb_proj’: 60})
epos.equalize_event_counts(conds)
_ , itc = epos[c].compute_tfr(method = “morlet”, freqs=freqs, n_cycles=n_cycles,
return_itc=True, average = True)
reading the profuced tfr file
tfrs = mne.time_frequency.read_tfrs(fname_in)
returns the following error:
Reading //Volumes/neurospin/meg/meg_tmp/2023_egoMEG_Wagelmans/MEG/tfr/ag230213_egoMEG_itc_combpresent-tfr.h5 …
TypeError Traceback (most recent call last)
File /Volumes/meg_tmp/2023_egoMEG_Wagelmans/SCRIPTS/tfr_ref_pipeline/008_TFR_iplot.py:65
61 fname_in = f’{tfr_dir}{subject}egoMEG{meas}_{c_names[0]}-tfr.h5’
64 # %%
—> 65 tfrs = mne.time_frequency.read_tfrs(fname_in)
70 #___plot power
71 # %%
72 tfrs[“ref/0_proj”].plot(picks=[“MEG2431”],
73 baseline = (-0.8, 0),
74 tmin = -0.5,
(…)
79 mode = “logratio”
80 )
File :12, in read_tfrs(fname, condition, verbose)
File ~/Applications/MNE-Python/1.10.1_0/.mne-python/lib/python3.13/site-packages/mne/time_frequency/tfr.py:4119, in read_tfrs(fname, condition, verbose)
4117 else:
4118 Klass = RawTFR
→ 4119 out = Klass(inst=hdf5_dict)
4120 if getattr(out, “metadata”, None) is not None:
4121 out.metadata = _prepare_read_metadata(out.metadata)
File ~/Applications/MNE-Python/1.10.1_0/.mne-python/lib/python3.13/site-packages/mne/time_frequency/tfr.py:2911, in AverageTFR.init(self, inst, freqs, method, tmin, tmax, picks, proj, decim, comment, n_jobs, verbose, **method_kw)
2909 else:
2910 self._comment = getattr(self, “_comment”, comment)
→ 2911 super().init(
2912 inst,
2913 method,
2914 freqs,
2915 tmin=tmin,
2916 tmax=tmax,
2917 picks=picks,
2918 proj=proj,
2919 decim=decim,
2920 n_jobs=n_jobs,
2921 verbose=verbose,
2922 **method_kw,
2923 )
File ~/Applications/MNE-Python/1.10.1_0/.mne-python/lib/python3.13/site-packages/mne/time_frequency/tfr.py:1194, in BaseTFR.init(self, inst, method, freqs, tmin, tmax, picks, proj, decim, n_jobs, reject_by_annotation, verbose, **method_kw)
1192 # triage reading from file
1193 if isinstance(inst, dict):
→ 1194 self.setstate(inst)
1195 return
1196 if method is None or freqs is None:
File ~/Applications/MNE-Python/1.10.1_0/.mne-python/lib/python3.13/site-packages/mne/time_frequency/tfr.py:2950, in AverageTFR.setstate(self, state)
2948 state[“dims”] += (“taper”,)
2949 state[“dims”] += (“freq”, “time”)
→ 2950 super().setstate(state)
2951 self._comment = state.get(“comment”, “”)
2952 self._nave = state.get(“nave”, 1)
File ~/Applications/MNE-Python/1.10.1_0/.mne-python/lib/python3.13/site-packages/mne/time_frequency/tfr.py:1436, in BaseTFR.setstate(self, state)
1434 self._raw_times = np.asarray(defaults[“times”], dtype=np.float64)
1435 self._baseline = defaults[“baseline”]
→ 1436 self.info = Info(**defaults[“info”])
1437 self._data_type = defaults[“data_type”]
1438 self._decim = defaults[“decim”]
File ~/Applications/MNE-Python/1.10.1_0/.mne-python/lib/python3.13/site-packages/mne/_fiff/meas_info.py:1698, in Info.init(self, *args, **kwargs)
1696 for key in (“helium_info”, “subject_info”):
1697 if key in self:
→ 1698 self[key] = self[key]
File ~/Applications/MNE-Python/1.10.1_0/.mne-python/lib/python3.13/site-packages/mne/_fiff/meas_info.py:960, in ValidatedDict.setitem(self, key, val)
958 raise RuntimeError(self._attributes[key])
959 else:
→ 960 val = self._attributes[key](
961 val, info=self
962 ) # attribute checker function
963 else:
964 class_name = self.class.name
File ~/Applications/MNE-Python/1.10.1_0/.mne-python/lib/python3.13/site-packages/mne/_fiff/meas_info.py:1010, in _check_types(x, info, name, types, cast)
1008 _validate_type(x, types, name)
1009 if cast is not None and x is not None:
→ 1010 x = cast(x)
1011 return x
File ~/Applications/MNE-Python/1.10.1_0/.mne-python/lib/python3.13/site-packages/mne/_fiff/meas_info.py:1053, in SubjectInfo.init(self, initial)
1051 super().init()
1052 for key, val in initial.items():
→ 1053 self[key] = val
File ~/Applications/MNE-Python/1.10.1_0/.mne-python/lib/python3.13/site-packages/mne/_fiff/meas_info.py:960, in ValidatedDict.setitem(self, key, val)
958 raise RuntimeError(self._attributes[key])
959 else:
→ 960 val = self._attributes[key](
961 val, info=self
962 ) # attribute checker function
963 else:
964 class_name = self.class.name
File ~/Applications/MNE-Python/1.10.1_0/.mne-python/lib/python3.13/site-packages/mne/_fiff/meas_info.py:1015, in _check_bday(birthday_input, info)
1014 def _check_bday(birthday_input, *, info):
→ 1015 date = _check_types(
1016 birthday_input,
1017 info=info,
1018 name=‘subject_info[“birthday”]’,
1019 types=(datetime.date, None),
1020 )
1021 # test if we have a pd.Timestamp
1022 if hasattr(date, “date”):
File ~/Applications/MNE-Python/1.10.1_0/.mne-python/lib/python3.13/site-packages/mne/_fiff/meas_info.py:1008, in _check_types(x, info, name, types, cast)
1007 def _check_types(x, *, info, name, types, cast=None):
→ 1008 _validate_type(x, types, name)
1009 if cast is not None and x is not None:
1010 x = cast(x)
File ~/Applications/MNE-Python/1.10.1_0/.mne-python/lib/python3.13/site-packages/mne/utils/check.py:645, in _validate_type(item, types, item_name, type_name, extra)
643 _item_name = “Item” if item_name is None else item_name
644 _item_type = type(item) if item is not None else item
→ 645 raise TypeError(
646 f"{_item_name} must be an instance of {type_name}{extra}, "
647 f"got {_item_type} instead."
648 )
TypeError: subject_info[“birthday”] must be an instance of date or None, got <class ‘tuple’> instead.
@sophie pointed. to this report Trouble with measurement dates when anonymizing or writing epochs data · Issue #13154 · mne-tools/mne-python · GitHub but it doesn’t seem to be identical.
Any pointer much appreciated
