|
32 | 32 | % - Tutorial FEM : https://neuroimage.usc.edu/brainstorm/Tutorials/FemMedianNerve :
|
33 | 33 | % - Tutorial ECOG : https://neuroimage.usc.edu/brainstorm/Tutorials/ECoG :
|
34 | 34 | % - Tutorial SEEG : https://neuroimage.usc.edu/brainstorm/Tutorials/Epileptogenicity :
|
| 35 | +% - NIRS : https://github.com/rob-luke/BIDS-NIRS-Tapping/tree/388d2cdc3ae831fc767e06d9b77298e9c5cd307b : |
| 36 | +% - NIRS : https://osf.io/b4wck/ : |
| 37 | + |
35 | 38 |
|
36 | 39 | % @=============================================================================
|
37 | 40 | % This function is part of the Brainstorm software:
|
|
209 | 212 | end
|
210 | 213 | return;
|
211 | 214 | end
|
| 215 | + |
| 216 | + % Add BIDS subject tag "sub-" if missing |
| 217 | + for iSubject = 1:length(OPTIONS.SelectedSubjects) |
| 218 | + if (length(OPTIONS.SelectedSubjects{iSubject}) <= 4) || ~strcmpi(OPTIONS.SelectedSubjects{iSubject}(1:4), 'sub-') |
| 219 | + OPTIONS.SelectedSubjects{iSubject} = ['sub-' OPTIONS.SelectedSubjects{iSubject}]; |
| 220 | + end |
| 221 | + end |
212 | 222 | OPTIONS.SelectedSubjects = unique([OPTIONS.SelectedSubjects, selSubjects]);
|
213 | 223 |
|
214 | 224 | % ===== FIND SUBJECTS =====
|
|
670 | 680 | end
|
671 | 681 | end
|
672 | 682 | % Loop on the supported modalities
|
673 |
| - for mod = {'meg', 'eeg', 'ieeg'} |
| 683 | + for mod = {'meg', 'eeg', 'ieeg','nirs'} |
674 | 684 | posUnits = 'mm';
|
675 | 685 | electrodesFile = [];
|
676 | 686 | electrodesSpace = 'ScanRAS';
|
|
709 | 719 | posUnits = sCoordsystem.EEGCoordinateUnits;
|
710 | 720 | elseif isfield(sCoordsystem, 'MEGCoordinateUnits') && ~isempty(sCoordsystem.MEGCoordinateUnits) && ismember(sCoordsystem.MEGCoordinateUnits, {'mm','cm','m'})
|
711 | 721 | posUnits = sCoordsystem.MEGCoordinateUnits;
|
| 722 | + elseif isfield(sCoordsystem, 'NIRSCoordinateUnits') && ~isempty(sCoordsystem.NIRSCoordinateUnits) && ismember(sCoordsystem.NIRSCoordinateUnits, {'mm','cm','m'}) |
| 723 | + posUnits = sCoordsystem.NIRSCoordinateUnits; |
712 | 724 | end
|
713 | 725 | % Get fiducials structure
|
714 | 726 | sFid = GetFiducials(sCoordsystem, posUnits);
|
|
720 | 732 | electrodesCoordSystem = sCoordsystem.EEGCoordinateSystem;
|
721 | 733 | elseif isfield(sCoordsystem, 'MEGCoordinateSystem') && ~isempty(sCoordsystem.MEGCoordinateSystem)
|
722 | 734 | electrodesCoordSystem = sCoordsystem.MEGCoordinateSystem;
|
| 735 | + elseif isfield(sCoordsystem, 'NIRSCoordinateSystem') && ~isempty(sCoordsystem.NIRSCoordinateSystem) |
| 736 | + electrodesCoordSystem = sCoordsystem.NIRSCoordinateSystem; |
723 | 737 | elseif ~isempty(coordsystemSpace)
|
724 | 738 | electrodesCoordSystem = coordsystemSpace;
|
725 | 739 | end
|
|
751 | 765 |
|
752 | 766 | % === ELECTRODES.TSV ===
|
753 | 767 | % Get electrodes positions
|
754 |
| - electrodesDir = dir(bst_fullfile(SubjectSessDir{iSubj}{isess}, mod{1}, '*_electrodes.tsv')); |
| 768 | + if strcmp(mod,'nirs') |
| 769 | + electrodesDir = dir(bst_fullfile(SubjectSessDir{iSubj}{isess}, mod{1}, '*_optodes.tsv')); |
| 770 | + else |
| 771 | + electrodesDir = dir(bst_fullfile(SubjectSessDir{iSubj}{isess}, mod{1}, '*_electrodes.tsv')); |
| 772 | + end |
755 | 773 | % If multiple positions in the same folder: not expected unless multiple coordinate systems are available
|
756 | 774 | if (length(electrodesDir) > 1)
|
757 | 775 | % Select by order of preference: subject space, MNI space or first in the list
|
|
822 | 840 | case '.eeg', FileFormat = 'EEG-BRAINAMP';
|
823 | 841 | case '.edf', FileFormat = 'EEG-EDF';
|
824 | 842 | case '.set', FileFormat = 'EEG-EEGLAB';
|
| 843 | + case '.snirf', FileFormat = 'NIRS-SNIRF'; |
825 | 844 | otherwise, FileFormat = [];
|
826 | 845 | end
|
827 | 846 | % Import file if file was identified
|
|
872 | 891 | % Read tsv file
|
873 | 892 | % For _channels.tsv, 'name', 'type' and 'units' are required.
|
874 | 893 | % 'group' and 'status' are fields added by Brainstorm export to BIDS.
|
875 |
| - ChanInfo = in_tsv(ChannelsFile, {'name', 'type', 'group', 'status'}, 0); |
| 894 | + if strcmp(mod,'nirs') |
| 895 | + ChanInfo_tmp = in_tsv(ChannelsFile, {'name','type','source','detector','wavelength_nominal', 'status'}); |
| 896 | + ChanInfo = cell(size(ChanInfo_tmp,1), 4); % {'name', 'type', 'group', 'status'} |
| 897 | + ChanInfo(:,2) = ChanInfo_tmp(:,2); |
| 898 | + ChanInfo(:,4) = ChanInfo_tmp(:,6); |
| 899 | + for i = 1:size(ChanInfo,1) |
| 900 | + ChanInfo{i,1} = sprintf('%s%sWL%d',ChanInfo_tmp{i,3},ChanInfo_tmp{i,4},str2double(ChanInfo_tmp{i,5})); |
| 901 | + ChanInfo{i,3} = sprintf('WL%d', str2double(ChanInfo_tmp{i,5})); |
| 902 | + end |
| 903 | + else |
| 904 | + ChanInfo = in_tsv(ChannelsFile, {'name', 'type', 'group', 'status'}); |
| 905 | + end |
| 906 | + |
876 | 907 | % Try to add info to the existing Brainstorm channel file
|
877 | 908 | % Note: this does not work if channel names different in data and metadata - see note in the function header
|
878 | 909 | if ~isempty(ChanInfo) || ~isempty(ChanInfo{1,1})
|
|
906 | 937 | chanType = 'MEG';
|
907 | 938 | case {'MEGREFMAG', 'MEGREFGRADAXIAL', 'MEGREFGRADPLANAR'} % CTF/4D references
|
908 | 939 | chanType = 'MEG REF';
|
| 940 | + case {'NIRSCWAMPLITUDE'} |
| 941 | + chanType = 'NIRS'; |
909 | 942 | end
|
910 | 943 | ChannelMat.Channel(iChanBst).Type = chanType;
|
911 | 944 | isModifiedChan = 1;
|
|
0 commit comments