Skip to content

Commit b212461

Browse files
committed
Script: Coherence tutorial, use CAT12-segmented MRI if present
1 parent 7e7a88e commit b212461

4 files changed

Lines changed: 37 additions & 21 deletions

File tree

doc/license.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<body alink="#fff000" link="#fff000" vlink="#fff000">
66
<h4><span style="font-family: Arial Black; color: #ffffff;"><strong>THERE IS NO UNDO BUTTON!<BR>SET UP A <FONT color=red>BACKUP</FONT> OF YOUR DATABASE</strong></span></h4>
77
<HR>
8-
<!-- LICENCE_START -->Version: 3.251024 (24-Oct-2025)<br>
8+
<!-- LICENCE_START -->Version: 3.251029 (29-Oct-2025)<br>
99
<span style="font-style: italic;">COPYRIGHT &copy; 2000-2025
1010
USC &amp; McGill University.<br>
1111
</span>

doc/updates.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
October 2025
2+
3+
--------------------------------------------------------------
14
September 2025
25
- Anatomy: Option to export fiducal locations alongside MRI file
36
- Anatomy: Option to align Surface to MRI, by setting fiducials in surface

toolbox/script/test_tutorial.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,9 @@ function test_tutorial(tutorialNames, dataDir, reportDir, bstUser, bstPwd)
127127
tutorial_connectivity();
128128

129129
case 'tutorial_coherence'
130-
dataFile = bst_fullfile(dataDir, 'SubjectCMC.zip');
130+
dataFile = get_tutorial_data(dataDir, 'SubjectCMC.zip', bstUser, bstPwd);
131131
if ~exist(dataFile, 'file')
132+
dataFile = bst_fullfile(dataDir, 'SubjectCMC.zip');
132133
bst_websave(dataFile, 'https://download.fieldtriptoolbox.org/tutorial/SubjectCMC.zip');
133134
end
134135
if exist(dataFile, 'file')

toolbox/script/tutorial_coherence.m

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,12 @@ function tutorial_coherence(tutorial_dir, reports_dir)
5151
% Build the path of the files to import
5252
MriFilePath = fullfile(tutorial_dir, 'SubjectCMC', 'SubjectCMC.mri');
5353
MegFilePath = fullfile(tutorial_dir, 'SubjectCMC', 'SubjectCMC.ds');
54+
MriCat12Path = fullfile(tutorial_dir, 'SubjectCMC', 'cat12');
5455
% Check if the folder contains the required files
5556
if ~file_exist(MriFilePath) || ~file_exist(MegFilePath)
5657
error(['The folder ' tutorial_dir ' does not contain the folder from the file SubjectCMC.zip.']);
5758
end
59+
isMriSegmented = file_exist(bst_fullfile(MriCat12Path, 'SubjectCMC.nii.gz'));
5860

5961

6062
%% ===== CREATE PROTOCOL =====
@@ -75,16 +77,24 @@ function tutorial_coherence(tutorial_dir, reports_dir)
7577

7678

7779
%% ===== IMPORT ANATOMY =====
78-
% Process: Import MRI
79-
bst_process('CallProcess', 'process_import_mri', [], [], ...
80-
'subjectname', SubjectName, ...
81-
'mrifile', {MriFilePath, 'ALL'}, ...
82-
'nas', [0, 0, 0], ...
83-
'lpa', [0, 0, 0], ...
84-
'rpa', [0, 0, 0], ...
85-
'ac', [0, 0, 0], ...
86-
'pc', [0, 0, 0], ...
87-
'ih', [0, 0, 0]);
80+
if ~isMriSegmented
81+
% Process: Import MRI
82+
bst_process('CallProcess', 'process_import_mri', [], [], ...
83+
'subjectname', SubjectName, ...
84+
'mrifile', {MriFilePath, 'ALL'}, ...
85+
'nas', [ 84, 229, 143], ...
86+
'lpa', [ 9, 116, 102], ...
87+
'rpa', [155, 114, 101]);
88+
else
89+
% Process: Import anatomy folder
90+
bst_process('CallProcess', 'process_import_anatomy', [], [], ...
91+
'subjectname', SubjectName, ...
92+
'mrifile', {MriCat12Path, 'CAT12'}, ...
93+
'nvertices', 15000, ...
94+
'nas', [ 84, 229, 143], ...
95+
'lpa', [ 9, 116, 102], ...
96+
'rpa', [155, 114, 101]);
97+
end
8898
% Process: Generate head surface
8999
bst_process('CallProcess', 'process_generate_head', [], [], ...
90100
'subjectname', SubjectName, ...
@@ -313,15 +323,17 @@ function tutorial_coherence(tutorial_dir, reports_dir)
313323

314324

315325
%% ===== SOURCE ESTIMATION =====
316-
% Process: Segment MRI with CAT12
317-
bst_process('CallProcess', 'process_segment_cat12', [], [], ...
318-
'subjectname', SubjectName, ...
319-
'nvertices', 15000, ...
320-
'tpmnii', {'', 'Nifti1'}, ...
321-
'sphreg', 1, ...
322-
'vol', 1, ...
323-
'extramaps', 0, ...
324-
'cerebellum', 0);
326+
if ~isMriSegmented
327+
% Process: Segment MRI with CAT12
328+
bst_process('CallProcess', 'process_segment_cat12', [], [], ...
329+
'subjectname', SubjectName, ...
330+
'nvertices', 15000, ...
331+
'tpmnii', {'', 'Nifti1'}, ...
332+
'sphreg', 1, ...
333+
'vol', 1, ...
334+
'extramaps', 0, ...
335+
'cerebellum', 0);
336+
end
325337
% Process: Compute covariance (noise or data)
326338
bst_process('CallProcess', 'process_noisecov', sFileRawNotchHighAbs, [], ...
327339
'baseline', [18, 29], ...

0 commit comments

Comments
 (0)