|
136 | 136 | FileUnits = 'm'; |
137 | 137 |
|
138 | 138 | % ===== EEG ONLY ===== |
139 | | - case {'BIDS-SCANRAS-MM', 'BIDS-MNI-MM', 'BIDS-ACPC-MM', 'BIDS-ALS-MM'} |
| 139 | + case {'BIDS-SCANRAS-MM', 'BIDS-MNI-MM', 'BIDS-ACPC-MM', 'BIDS-ALS-MM', 'BIDS-CAPTRAK-MM'} |
140 | 140 | ChannelMat = in_channel_bids(ChannelFile, 0.001); |
141 | 141 | FileUnits = 'mm'; |
142 | | - case {'BIDS-SCANRAS-CM', 'BIDS-MNI-CM', 'BIDS-ACPC-CM', 'BIDS-ALS-CM'} |
| 142 | + case {'BIDS-SCANRAS-CM', 'BIDS-MNI-CM', 'BIDS-ACPC-CM', 'BIDS-ALS-CM', 'BIDS-CAPTRAK-CM'} |
143 | 143 | ChannelMat = in_channel_bids(ChannelFile, 0.01); |
144 | 144 | FileUnits = 'cm'; |
145 | | - case {'BIDS-SCANRAS-M', 'BIDS-MNI-M', 'BIDS-ACPC-M', 'BIDS-ALS-M'} |
| 145 | + case {'BIDS-SCANRAS-M', 'BIDS-MNI-M', 'BIDS-ACPC-M', 'BIDS-ALS-M', 'BIDS-CAPTRAK-M'} |
146 | 146 | ChannelMat = in_channel_bids(ChannelFile, 1); |
147 | 147 | FileUnits = 'm'; |
148 | 148 |
|
|
410 | 410 | warning(['WARNING: When importing ACPC positions for multiple subjects: the ACPC transformation from the first subject is used for all of them.' 10 ... |
411 | 411 | 'Please consider importing your subjects seprately.']); |
412 | 412 | end |
413 | | - % If we know the destination study: convert from MNI to SCS coordinates |
| 413 | + % If we know the destination study: convert from ACPC to SCS coordinates |
414 | 414 | if ~isempty(iStudies) |
415 | 415 | % Get the subject for the first study |
416 | 416 | sStudy = bst_get('Study', iStudies(1)); |
|
433 | 433 | % Do not convert the positions to SCS |
434 | 434 | isAlignScs = 0; |
435 | 435 |
|
| 436 | +%% ===== CAPTRAK TRANSFORMATION ===== |
| 437 | +elseif ismember(FileFormat, {'BIDS-CAPTRAK-MM', 'BIDS-CAPTRAK-CM', 'BIDS-CAPTRAK-M'}) |
| 438 | + % Warning for multiple studies |
| 439 | + if (length(iStudies) > 1) |
| 440 | + warning(['WARNING: When importing CapTrak positions for multiple subjects: the CapTrak transformation from the first subject is used for all of them.' 10 ... |
| 441 | + 'Please consider importing your subjects seprately.']); |
| 442 | + end |
| 443 | + % If we know the destination study: convert from CapTrak to SCS coordinates |
| 444 | + if ~isempty(iStudies) |
| 445 | + % Get the subject for the first study |
| 446 | + sStudy = bst_get('Study', iStudies(1)); |
| 447 | + sSubject = bst_get('Subject', sStudy.BrainStormSubject); |
| 448 | + % Get the subject's MRI |
| 449 | + if isempty(sSubject.Anatomy) || isempty(sSubject.Anatomy(1).FileName) |
| 450 | + error('You need the subject anatomy in order to load sensor positions in CapTrak coordinates.'); |
| 451 | + end |
| 452 | + % Load the MRI |
| 453 | + MriFile = file_fullpath(sSubject.Anatomy(1).FileName); |
| 454 | + sMri = in_mri_bst(MriFile); |
| 455 | + if ~isfield(sMri, 'SCS') || ~isfield(sMri.SCS, 'R') || isempty(sMri.SCS.R) || ~isfield(sMri.SCS, 'NAS') || isempty(sMri.SCS.NAS) || ~isfield(sMri.SCS, 'LPA') || isempty(sMri.SCS.LPA) || ~isfield(sMri.SCS, 'RPA') || isempty(sMri.SCS.RPA) |
| 456 | + error(['All fiducials must be defined for this subject (NAS,LPA,RPA)' 10 'in order to load sensor positions in CapTrak coordinates.']); |
| 457 | + end |
| 458 | + % Convert all the coordinates: CapTrak => SCS |
| 459 | + fcnTransf = @(Loc)cs_convert(sMri, 'captrak', 'scs', Loc')'; |
| 460 | + AllChannelMats = channel_apply_transf(ChannelMat, fcnTransf, [], 1); |
| 461 | + ChannelMat = AllChannelMats{1}; |
| 462 | + end |
| 463 | + % Do not convert the positions to SCS |
| 464 | + isAlignScs = 0; |
| 465 | + |
436 | 466 | %% ===== MRI/NII TRANSFORMATION ===== |
437 | 467 | % If the SCS coordinates are not defined (NAS/LPA/RPA fiducials), try to use the MRI=>subject transformation available in the MRI (eg. NIfTI sform/qform) |
438 | 468 | % Only available if there is one study in output |
|
0 commit comments