Skip to content
Snippets Groups Projects

Main

Open Paparella Ilenia requested to merge ipaparella/mrs-gaba-nmm:main into main
6 files
+ 452
0
Compare changes
  • Side-by-side
  • Inline
Files
6
+ 59
0
%% CODE TO CREATE GCM - GIT
% This code needs the usual your_paths.txt file.
% Once the NMM model is run, this code
% will create a GCM file to input in the PEB analysis.
%-----------------------------------------------------------------------
% Written by I. Paparella
% Cyclotron Research Centre, University of Liege, Belgium
% 14th December 2023
function Create_GCMs
%% Path info
paths_txt = fileread('your_paths.txt') ;
paths_txt = char(strsplit(paths_txt, '\n')) ;
pathtodata = (strtrim(paths_txt(2,:)));
%% Pre define variables
GCM = [];
%% Select the subject to analyse
cd(pathtodata);
[subdir] = spm_select(Inf,'dir','Select subject_ID directory');
IDs = str2num(subdir(:,end-2:end));
%% Loop across subjects
for isub = 1:size(subdir,1)
subject_ID = sprintf('sub-%03d', IDs(isub));
subject_Path = strcat (pathtodata, '/', subject_ID, '/TMS_EEG');
% Go in the session folder and load DCM
DCMfile_sess=spm_select('List',subject_Path,'DCM_DefaultCodes_.*.mat$');
if isempty(DCMfile_sess)
warning('No DCM for subject %s, session %s was found. Please check the subjects you selected', subject_ID, session)
return
end
Loaded_DCMfile_sess = load(strcat(subject_Path, '/', DCMfile_sess));
% Fill the GCM according to the session with all subjects together
GCM = [GCM; {Loaded_DCMfile_sess.DCM}];
end
% Make PEB directory
mkdir(strcat(pathtodata,'/PEB'));
% Save GCM with the correct naming
nameTosav= 'allFemale';
GCM = GCM;
save(strcat(pathtodata,'/PEB/', sprintf('GCM_%s_%s', session, nameTosav)), 'GCM')
fprintf('GCM has been created. \n')
end
\ No newline at end of file
Loading