|
79 | 79 | _handle_datatype, |
80 | 80 | _import_nibabel, |
81 | 81 | _infer_eeg_placement_scheme, |
| 82 | + _infer_emg_placement_scheme, |
82 | 83 | _stamp_to_dt, |
83 | 84 | _write_json, |
84 | 85 | _write_text, |
@@ -1008,7 +1009,8 @@ def _sidecar_json( |
1008 | 1009 | ch_info_json_emg = [ |
1009 | 1010 | ("EMGReference", "n/a"), |
1010 | 1011 | ("EMGGround", "n/a"), |
1011 | | - ("EMGPlacementScheme", "n/a"), |
| 1012 | + # TODO EMG: must be one of Measured, ChannelSpecific, Other |
| 1013 | + ("EMGPlacementScheme", _infer_emg_placement_scheme(raw)), |
1012 | 1014 | ("Manufacturer", manufacturer), |
1013 | 1015 | ] |
1014 | 1016 |
|
@@ -2050,6 +2052,10 @@ def write_raw_bids( |
2050 | 2052 | # if we have an available DigMontage |
2051 | 2053 | if montage is not None or (raw.info["dig"] is not None and raw.info["dig"]): |
2052 | 2054 | _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 |
2053 | 2059 | else: |
2054 | 2060 | logger.info( |
2055 | 2061 | f"Writing of electrodes.tsv is not supported " |
@@ -2202,12 +2208,22 @@ def write_raw_bids( |
2202 | 2208 | else bids_path.fpath |
2203 | 2209 | ), |
2204 | 2210 | ) |
2205 | | - elif bids_path.datatype in ["eeg", "ieeg"] and format == "EDF": |
| 2211 | + elif bids_path.datatype in ["eeg", "emg", "ieeg"] and format == "EDF": |
2206 | 2212 | warn("Converting data files to EDF format") |
| 2213 | + bids_path.update(extension=".edf") |
2207 | 2214 | _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.") |
2208 | 2218 | elif bids_path.datatype in ["eeg", "ieeg"] and format == "EEGLAB": |
2209 | 2219 | warn("Converting data files to EEGLAB format") |
2210 | 2220 | _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) |
2211 | 2227 | else: |
2212 | 2228 | warn("Converting data files to BrainVision format") |
2213 | 2229 | bids_path.update(suffix=bids_path.datatype, extension=".vhdr") |
|
0 commit comments