Repository navigation
Expand file tree
/
Copy pathStep1_SPECT_Template_Conversion.m
More file actions
51 lines (45 loc) · 2.9 KB
/
Copy pathStep1_SPECT_Template_Conversion.m
File metadata and controls
51 lines (45 loc) · 2.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
%% beginning of all sc-ICA scripts (steps 1-7)
%each script has a specific function, whether it be plotting, doing
%analysis, or cleaning components for presentation
%%Updates as of 3/4/2026
%Script has been updated to account for within/domain reordering IN
%ADDITION to sorting the components by domain/subdomain
%%
%loadBlind_ICA_FNC_matrix_CoMod_matrix_display Workspace
%2/21/2026 Update:
%redo group vs. group_reordered variable to sort components by
%domain/subdomain
%2/25 /26 Update: Second QC, removed a white matter comp and also
%relabelled comp 7 from original order as it was not cerebellum, but DM.
cd '/Users/amrithah/Desktop/CalhounLab/Dissertation/Projects/Chapter6_Paper_5_SPECT Template/SPECT Template Creation/Blind_ICA_Results/Round 2/SPECT_Secondary_Blind_ICA_Round2_Results/SPECT_Template_Blind_ICA_Dataset2_5000_subj_sbm_results_Round1'
niiFile = 'SPECT_Template_Blind_ICA_Dataset2_5000_subj_group_component_ica_.nii'; %load first batch of subjects
outFile = 'NeuroMarkSPECTTemplate.nii';
%% Load full NIfTI (100 components)
Vfull = spm_vol(niiFile);
Yfull = spm_read_vols(Vfull);
%% -----------------------------------------
%% group_resorted defines the new order (1:68), and then reorder within domain
%% -----------------------------------------
%load updated labels with within domain reordering; reordered within domain order
%% Step 2: Final index vector to apply to your data matrix
selectedIdx_final = Run1; %call Run 1, reordered indices from 4/3/2026 based on matched run 1 on newly rerun blind ICA from run 2
%% Extract the 60 reordered components
Vnew = Vfull(selectedIdx_final);
Ynew = Yfull(:,:,:,selectedIdx_final);
%% -----------------------------------------
%% Write output NIfTI with indices 1:68
%% -----------------------------------------
for i = 1:length(selectedIdx_final)
Vout = Vnew(i); % header for the i-th reordered component
Vout.fname = outFile; % same output file
Vout.n = [i 1]; % write as volume i (1–68)
spm_write_vol(Vout, Ynew(:,:,:,i));
end
%% move NeuroMark template to main folder
sourceFile = '/Users/amrithah/Desktop/CalhounLab/Dissertation/Projects/Chapter6_Paper_5_SPECT Template/SPECT Template Creation/Blind_ICA_Results/Round 2/SPECT_Secondary_Blind_ICA_Round2_Results/SPECT_Template_Blind_ICA_Dataset2_5000_subj_sbm_results_Round1/NeuroMarkSPECTTemplate.nii';
destinationFolder = '/Users/amrithah/Desktop/CalhounLab/Dissertation/Projects/Chapter6_Paper_5_SPECT Template/Scripts/sc-ICA';
movefile(sourceFile, destinationFolder);
% go to blind ICA CoM path and run scripts if you haven't done so
cd '/Users/amrithah/Desktop/CalhounLab/Dissertation/Projects/Chapter6_Paper_5_SPECT Template/GIFT Autolabeller Tool/Round_2_Results/SPECT_Autolabeller_Round2/Scripts'
%% now run sc ICA CoM scripts, go to working directory
cd '/Users/amrithah/Desktop/CalhounLab/Dissertation/Projects/Chapter6_Paper_5_SPECT Template/Scripts/sc-ICA'