Skip to content

Commit 347dab7

Browse files
committed
more WIP changes [ci skip]
1 parent 9026973 commit 347dab7

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

mne_bids/config.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@
1919

2020
MEG_CONVERT_FORMATS = ["FIF", "auto"]
2121
EEG_CONVERT_FORMATS = ["BrainVision", "auto"]
22+
EMG_CONVERT_FORMATS = ["EDF", "BDF", "auto"]
2223
IEEG_CONVERT_FORMATS = ["BrainVision", "auto"]
2324
NIRS_CONVERT_FORMATS = ["auto"]
2425
CONVERT_FORMATS = {
2526
"meg": MEG_CONVERT_FORMATS,
2627
"eeg": EEG_CONVERT_FORMATS,
28+
"emg": EMG_CONVERT_FORMATS,
2729
"ieeg": IEEG_CONVERT_FORMATS,
2830
"nirs": NIRS_CONVERT_FORMATS,
2931
}
@@ -140,6 +142,9 @@
140142

141143
allowed_extensions_emg = [
142144
".edf", # European Data Format
145+
".bdf", # Biosemi
146+
# TODO EMG: .bdf support awaits https://github.com/the-siesta-group/edfio/issues/62
147+
# and corresponding downstream changes in MNE-Python and here in MNE-BIDS
143148
]
144149

145150
allowed_extensions_ieeg = [

mne_bids/utils.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,11 @@ def _get_mrk_meas_date(mrk):
294294
return meas_datetime
295295

296296

297+
def _infer_emg_placement_scheme(raw):
298+
# TODO EMG: just a placeholder, may not even need to exist in the end
299+
pass
300+
301+
297302
def _infer_eeg_placement_scheme(raw):
298303
"""Based on the channel names, try to infer an EEG placement scheme.
299304

mne_bids/write.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
_handle_datatype,
8080
_import_nibabel,
8181
_infer_eeg_placement_scheme,
82+
_infer_emg_placement_scheme,
8283
_stamp_to_dt,
8384
_write_json,
8485
_write_text,
@@ -1008,7 +1009,8 @@ def _sidecar_json(
10081009
ch_info_json_emg = [
10091010
("EMGReference", "n/a"),
10101011
("EMGGround", "n/a"),
1011-
("EMGPlacementScheme", "n/a"),
1012+
# TODO EMG: must be one of Measured, ChannelSpecific, Other
1013+
("EMGPlacementScheme", _infer_emg_placement_scheme(raw)),
10121014
("Manufacturer", manufacturer),
10131015
]
10141016

@@ -2050,6 +2052,10 @@ def write_raw_bids(
20502052
# if we have an available DigMontage
20512053
if montage is not None or (raw.info["dig"] is not None and raw.info["dig"]):
20522054
_write_dig_bids(bids_path, raw, montage, acpc_aligned, overwrite)
2055+
elif bids_path.datatype == "emg":
2056+
# TODO EMG: this is where to handle EMG coordsystem. We're not going to have a
2057+
# DigMontage (probably) so need another way to intake the info
2058+
pass
20532059
else:
20542060
logger.info(
20552061
f"Writing of electrodes.tsv is not supported "
@@ -2202,12 +2208,22 @@ def write_raw_bids(
22022208
else bids_path.fpath
22032209
),
22042210
)
2205-
elif bids_path.datatype in ["eeg", "ieeg"] and format == "EDF":
2211+
elif bids_path.datatype in ["eeg", "emg", "ieeg"] and format == "EDF":
22062212
warn("Converting data files to EDF format")
2213+
bids_path.update(extension=".edf")
22072214
_write_raw_edf(raw, bids_path.fpath, overwrite=overwrite)
2215+
elif bids_path.datatype in ["emg"] and format == "BDF":
2216+
# TODO EMG
2217+
raise NotImplementedError("Conversion to BDF not yet supported.")
22082218
elif bids_path.datatype in ["eeg", "ieeg"] and format == "EEGLAB":
22092219
warn("Converting data files to EEGLAB format")
22102220
_write_raw_eeglab(raw, bids_path.fpath, overwrite=overwrite)
2221+
elif bids_path.datatype in ["emg"]:
2222+
# TODO EMG: when writing to BDF is possible, that will be the default here
2223+
# instead. cf: https://github.com/the-siesta-group/edfio/issues/62
2224+
bids_path.update(extension=".edf")
2225+
warn("Converting data files to EDF format")
2226+
_write_raw_edf(raw, bids_path.fpath, overwrite=overwrite)
22112227
else:
22122228
warn("Converting data files to BrainVision format")
22132229
bids_path.update(suffix=bids_path.datatype, extension=".vhdr")

0 commit comments

Comments
 (0)