OSCR

Multimodal approach to identify neuropsychophysiological subgroups in myalgic encephalomyelitis/chronic fatigue syndrome and their relevance for rehabilitation: protocol for a mechanistic cross-sectional and longitudinal study.

Code ↔ Paper

16 matches between paragraphs of the paper and lines of its authors' code, computed by the harvester (lexical-v1). Click a colored paragraph or line to see its counterpart.

The 16 matches · 5 of them tie a paragraph to a whole file, not to given lines: weak matches, whose lines are not tinted
  1. [1] § CRediT authorship contribution statement ↔ pet/scripts/LaBGAScore_pet_model_TSPO_DPA714.m, lines 1–106 · score 0.69 · Lixin Qiu, Lukas Van Oudenhove, Patrick Dupont
  2. [2] § Methods › Neuroimaging data › Preprocessing › PET ↔ pet/scripts/LaBGAScore_pet_model_TSPO_DPA714.m, lines 1–106 · score 0.68 · endothelial binding, DPA714, SPM, parcels, blood, ROIs
  3. [3] § Methods › Measures › Primary outcome variables › Neuroimaging › PET/MR scan protocol ↔ pet/functions/LCN12_PET_preprocessing.m, lines 1–76 · score 0.67 · attenuation correction, T1 weighted, injection, DPA714, dynamic, scanning
  4. [4] § Methods › Statistical analysis plan › Objective 1: comparison of neuropsychophysiological measures between ME/CFS patients and healthy participants › Brain resting-state fMRI ↔ secondlevel/functions/tfce_volume.m, the whole file · a weak match · score 0.67 · Threshold Free Cluster, Enhancement, TFCE, connectivity, Voxel, error
  5. [5] § Methods › Neuroimaging data › Preprocessing › MRS ↔ mrs/LaBGAScore_mrs_run_osprey_GE.m, lines 230–316 · score 0.66 · linear combination, water scaled, Osprey, spectra, quality, quantification
  6. [6] § Methods › Neuroimaging data › Preprocessing › MRS ↔ mrs/LaBGAScore_mrs_run_osprey_Philips.m, lines 230–316 · score 0.66 · linear combination, water scaled, Osprey, spectra, quality, quantification
  7. [7] § Methods › Statistical analysis plan › Objective 1: comparison of neuropsychophysiological measures between ME/CFS patients and healthy participants › Brain resting-state fMRI ↔ secondlevel/functions/tfce_transform_3d.m, the whole file · a weak match · score 0.66 · Threshold Free Cluster, Enhancement, TFCE, connectivity, Voxel, error
  8. [8] § Methods › Statistical analysis plan › Objective 1: comparison of neuropsychophysiological measures between ME/CFS patients and healthy participants › Brain task-based fMRI ↔ Second_level_analysis_template_scripts/b_copy_to_local_scripts_dir_and_modify/a2_set_default_options.m, lines 383–401 · score 0.66 · multivariate mediation, gray matter mask, FDR correction, PDM, CANlab, threshold
  9. [9] § Methods › Neuroimaging data › Preprocessing › PET ↔ pet/functions/LCN12_write_image.m, the whole file · a weak match · score 0.61 · University College London, Wellcome, SPM12, volume, MATLAB, PET
  10. [10] § Methods › Statistical analysis plan › Objective 4: use these subgroups as potential predictors of longitudinal effects throughout treatment ↔ canlab_mixed_effects_matlab_demo1/canlab_mixed_model_example.r, the whole file · a weak match · score 0.61 · linear mixed models, model fit, intercept
  11. [11] § Methods › Statistical analysis plan › Objective 1: comparison of neuropsychophysiological measures between ME/CFS patients and healthy participants › Brain task-based fMRI ↔ decoding_toolbox/LaBGAScore_decoding_SVM_between_subjects.m, lines 1193–1296 · score 0.61 · Decoding Toolbox, cross validate, shuffling, classifier, train, fold
  12. [12] § CRediT authorship contribution statement ↔ pet/functions/LCN12_PET_preprocessing.m, lines 1–76 · score 0.55 · Lukas Van Oudenhove, Patrick Dupont, editing
  13. [13] § Methods › Neuroimaging data › ROI definition › Task-based fMRI (Montreal Imaging Stress Test) ↔ example_help_files/canlab_help_9_apply_a_multivariate_pattern_of_interest.m, the whole file · a weak match · score 0.54 · anterior cingulate, fMRI, dorsal, ROI
  14. [14] § Methods › Measures › Primary outcome variables › Neuroimaging › MRI scan protocol ↔ mrs/LaBGAScore_mrs_osprey_single_sess_jobfile_Philips.m, lines 262–351 · score 0.54 · T1 weighted, Philips, MRS, scanning, sequence, quantified
  15. [15] § Methods › Measures › Primary outcome variables › Neuroimaging › MRI scan protocol ↔ mrs/LaBGAScore_mrs_osprey_jobfile_Philips.m, lines 262–361 · score 0.54 · T1 weighted, Philips, MRS, scanning, sequence, quantified
  16. [16] § Methods › Statistical analysis plan › Objective 1: comparison of neuropsychophysiological measures between ME/CFS patients and healthy participants › SRS, SCFAs, fatigue/fatigability, immune markers ↔ stats_tools/functions/LaBGAScore_Storey_FDR.m, lines 1–60 · score 0.50 · Benjamini Hochberg, pFDR, spline, bootstrap, CFS

Paper

Loaded from Europe PMC by your browser, not stored by OSCR: doi.org · Europe PMC

The paper is loaded when this pane is shown.

The authors' code

MATLAB · 1,435 lines · 79 KB · GPL-3.0 · 2 matches

  1. %% LaBGAScore_pet_model_TSPO_DPA714.m
  2. %
  3. %
  4. % *USAGE*
  5. %
  6. % Assumptions:
  7. % Data are organized according to BIDS.
  8. % You have to specify a main directory where al the folders of the
  9. % subjects can be found.
  10. % In the folder of each subject, there might be a folder ses-xx
  11. % which contains the folder anat with the T1 weighted structural MRI
  12. % and a folder pet which contains the dynamic PET images.
  13. % If the folder ses-xx is not existing, we assume that the subfolder
  14. % anat and pet are directly under the main folder of the subject.
  15. %
  16. % The data are preprocessed using LCN12_PET_preprocess_data.m
  17. %
  18. % A template for the PET naming should be specified. PET data are
  19. % acquired dynamically from the start of the injection. The unit of
  20. % the PET data is expresses as Bq/ml.Images are decay corrected to
  21. % the start of the injection/begin of scanning.
  22. % We assume that PET data are in 4D nifti format.
  23. % In the pet folder, there must be a .m file containing the frame
  24. % defintion by specifying the variable frames_timing which is a N x 2
  25. % or N x 3 array (N = number of frames) for which the first column is
  26. % the start time of the frame in seconds post injection, the second
  27. % column is the end time of each frame and the third column is
  28. % optional with the weight for the frame (positive values). If
  29. % weights are not specified, all frames are weighted in the same way.
  30. %
  31. %
  32. % *OPTIONS*
  33. %
  34. % All set in the "PREP WORK, SET INFO AND OPTIONS" section, above the
  35. % "DO NOT CHANGE BELOW THIS LINE" marker:
  36. %
  37. % * sessiondir default '', session subfolder name (empty = no session level)
  38. % * infostring_tracer default 'trc-DPA714', tracer identifier used in filenames
  39. % * infostring_PET default 'rec-acdyn_pet', PET-image filename suffix
  40. % * infostring_frames default 'frames', frame-definition .m filename suffix
  41. % * infostring_input default 'data_blood', arterial input function filename suffix (only needed for models requiring one)
  42. % * infostring_metab default 'data_metab', metabolite filename suffix (only needed for models requiring one)
  43. % * SUBJECTS which subjects to analyze - three alternative strategies in-code (all-PET-in-BIDS, all-in-derivatives, or manual list); default uses "all subjects in derivatives/pet"
  44. % * figures_on default 0, show per-region figures and pause (needs keypress) if 1
  45. % * save_figures default 1, save figures to file (overrules pausing)
  46. % * save_parcelimgs default 0, save parcel-wise images per parameter/model/subject if 1
  47. % * do_voxelwise_logan default 0, also run voxel-wise Logan analysis if 1
  48. % * pet_space_reference default 0, read atlas in PET space (1) vs. atlas space (0)
  49. % * suffix default 'atlas_space', label used when running multiple models
  50. % * atlas_name default 'canlab2024_fine_2mm' - option (a) whole-brain atlas name for load_atlas.m, or option (b, commented) a combined-ROI .nii from LaBGAScore_atlas_rois_from_atlas.m
  51. % * intersect_GM / intersect_WM default 0/0, intersect VOI/parametric image with subject-specific GM/WM mask
  52. % * GM_CUTOFF / WM_CUTOFF default 0.3/0.3, thresholds for the above
  53. % * additional_smooth_parametric default 6 (mm), isotropic Gaussian smoothing kernel for voxel-based parametric Logan images
  54. % * nr_parpool default 12 (LaBGAS server default), number of parallel workers
  55. %
  56. %
  57. % *DEPENDENCIES*
  58. %
  59. % * CanlabCore: load_atlas, downsample_parcellation
  60. % * SPM: spm_vol
  61. % * vendored pet/functions/LCN_*.m: LCN12_read_image, LCN_check_filename, LCN_calc_intact_tracer_hill (and related LCN model-fitting functions)
  62. %
  63. %
  64. % *NOTES*
  65. %
  66. % THIS IS RESEARCH SOFTWARE. Originated as LCN12_PET_TSPO_DPA714.m (v2.0).
  67. %
  68. % History:
  69. % February 2024: an excel file is written which contains for all
  70. % subjects and all regions, the volume of distribution
  71. % and the error of the fit.
  72. % March 2024: adapted to work with standard LaBGAS file
  73. % organization (LVO) and adapted version of
  74. % preprocessing script
  75. % LaBGAScore_pet_preprocess_data
  76. % built in check for enough frames after
  77. % logan_start_time (LVO)
  78. % May 2024 further adaptations to fit LaBGAS file organization (LVO)
  79. % built in more options for automatic subject and ROI definition (LVO)
  80. % November 2024: removal of Global variables and adding parallel processing
  81. % January 2025: weights for excluded frames set to zero and decay
  82. % between measurement samples and start scan is now
  83. % taken into account
  84. % April 2025: Logan is also done voxel based
  85. % May 2025: Built in option to work with canlab atlas objects (LVO)
  86. % Final adaptations to fit LaBGAS file organisation (LVO)
  87. % Added atlas labels automatically to output files (LVO)
  88. % Sept 2025: Integration of LCN12_PET_TSPO_DPA714_compare_models.m (v0.2)
  89. % ~ includes 2T4k models with (ir)reversible endothelial binding
  90. % component and fit statistics to compare models
  91. % (LVO)
  92. %
  93. % -------------------------------------------------------------------------
  94. %
  95. % modified by: Patrick Dupont, Lukas Van Oudenhove, Lixin Qiu
  96. %
  97. % date: October 2023
  98. %
  99. % -------------------------------------------------------------------------
  100. %
  101. % LaBGAScore_pet_model_TSPO_DPA714.m v2.1
  102. %
  103. % last modified: 2026/08/20
  104. clear
  105. close all
  106. %% PREP WORK, SET INFO AND OPTIONS
  107. %--------------------------------------------------------------------------
  108. % SET DIRECTORIES
  109. LaBGAScore_prep_s0_define_directories; % MAKE STUDY-SPECIFIC
  110. maindir = BIDSdir; % directory where the folders of each subject can be found
  111. sessiondir = ''; % if empty, we assume that there is no folder session and the folders anat and pet are directly under the subject folder
  112. infostring_tracer = 'trc-DPA714';
  113. infostring_PET = 'rec-acdyn_pet'; % the PET data are "subjectname"_"sessiondir"_"infostring_tracer"_"infostring_PET".nii (example = sub-test_trc-DPA714_rec-acdyn_pet.nii)
  114. infostring_frames = 'frames'; % in the folder pet, we assume a .m file name "subjectname"_"sessiondir"_"infostring_tracer"_"infostring_PET"_"infostring_frames".m (example sub-test_trc-DPA714_rec-acdyn_pet_frames.m)
  115. % infostring_input and infostring_metab need only be defined if we use
  116. % models which require an arterial input function
  117. infostring_input = 'data_blood'; % % in the folder pet, we assume a .m file name "subjectname"_"sessiondir"_"infostring_tracer"_"infostring_input".m (example sub-test_trc-DPA714_rec-acdyn_data_blood.nii)
  118. infostring_metab = 'data_metab'; % % in the folder pet, we assume a .m file name "subjectname"_"sessiondir"_"infostring_tracer"_"infostring_metab".m (example sub-test_trc-DPA714_rec-acdyn_data_metab.nii)
  119. % Lukas' code to take into account that preprocessed data are in
  120. % derivatives/pet-<infostring_tracer>
  121. derivrootdir = fileparts(derivdir);
  122. derivpetdir = fullfile(derivrootdir,['pet_' infostring_tracer]);
  123. firstlevelpetdir = fullfile(rootdir,'firstlevel',['pet_' infostring_tracer]);
  124. if ~exist(firstlevelpetdir,'dir')
  125. mkdir(firstlevelpetdir);
  126. end
  127. secondlevelpetdir = fullfile(rootdir,'secondlevel',['pet_' infostring_tracer]);
  128. if ~exist(secondlevelpetdir,'dir')
  129. mkdir(secondlevelpetdir);
  130. end
  131. secondlevelpetmaskdir = fullfile(secondlevelpetdir,'masks');
  132. if ~exist(secondlevelpetmaskdir,'dir')
  133. mkdir(secondlevelpetmaskdir);
  134. end
  135. secondlevelpetresultsdir = fullfile(secondlevelpetdir,'results');
  136. if ~exist(secondlevelpetresultsdir,'dir')
  137. mkdir(secondlevelpetresultsdir);
  138. end
  139. secondlevelpetroidir = fullfile(secondlevelpetmaskdir,'rois');
  140. if ~exist(secondlevelpetroidir,'dir')
  141. mkdir(secondlevelpetroidir);
  142. end
  143. % SELECT SUBJECTS
  144. % Lukas' code to automate selection of subjects who have a pet dir in BIDS
  145. % USE THIS FOR ANALYZING ALL PET SUBJECTS AT ONCE
  146. % dir_BIDS = dir(fullfile(BIDSdir,'sub-*'));
  147. %
  148. % petsubcounter = 1;
  149. %
  150. % for sub = 1:size(dir_BIDS,1)
  151. % BIDSsubdir = fullfile(BIDSdir,dir_BIDS(sub).name);
  152. % dir_BIDSsubdir = dir(BIDSsubdir);
  153. % if contains([dir_BIDSsubdir(:).name],'pet')
  154. % SUBJECTS{petsubcounter,1} = dir_BIDS(sub).name;
  155. % petsubcounter = petsubcounter + 1;
  156. % else
  157. % continue
  158. % end
  159. % end
  160. %
  161. % dir_derivpet = dir(fullfile(derivpetdir,'sub-*'));
  162. %
  163. % if ~isequal(SUBJECTS,{dir_derivpet(:).name}')
  164. % error('#subjects with PET data in BIDS and derivatives subdatasets does not match, please preprocess all subjects before proceeding');
  165. % end;
  166. % Lukas' code to automate selection of subjects in derivatives/pet
  167. % USE THIS FOR ANALYZING ALL PET SUBJECTS AT ONCE WITHOUT CHECKING CONSISTENCY BETWEEN BIDS AND DERIVATIVES SUBDATASETS
  168. dir_derivpet = dir(fullfile(derivpetdir,'sub-*'));
  169. SUBJECTS = {dir_derivpet(:).name}';
  170. % Patrick's code to enter subjects manually
  171. % USE THIS FOR ANALYZING SELECTED SUBJECTS
  172. % SUBJECTS = {
  173. % 'sub-KUL034'
  174. % };
  175. % SET FIGURE/IMAGE OPTIONS
  176. figures_on = 0; % if 1, we show the figures for each region and pause. You need to hit a key to proceed.
  177. save_figures = 1; % if 1, we save the figures to file and pausing of figures is overruled.
  178. save_parcelimgs = 0; % if 1, we save parcel-wise images for every parameter in every model for every subject
  179. do_voxelwise_logan = 0; % if 1, we perform a voxel-wise Logan analysis in addition to the parcel-wise analyses
  180. pet_space_reference = 0; % if 1, atlas is read in pet space. Voxels with non-integer values (i.e. voxels at the border of a region) will be excluded. If 0, atlas space is used.
  181. suffix = 'atlas_space'; % use if you want to run multiple models
  182. % DEFINE ATLAS/ROIS
  183. % Lukas' code to flexibly load canlab atlas objects
  184. % option a - atlas name from load_atlas.m for whole-brain parcellation
  185. atlas_name = 'canlab2024_fine_2mm';
  186. atlas = load_atlas(atlas_name);
  187. atlas = downsample_parcellation(atlas,'labels_3'); % downsample to intermediate granularity level, 246 parcels
  188. atlas.probability_maps = [];
  189. atlas_filename = fullfile(secondlevelpetmaskdir,[atlas_name '.nii']);
  190. if ~isfile(atlas_filename)
  191. write(atlas,'fname',atlas_filename);
  192. end
  193. % option b - combined roi .nii file generated by
  194. % https://github.com/labgas/LaBGAScore/blob/main/atlas_mask_tools/LaBGAScore_atlas_rois_from_atlas.m
  195. % for roi analysis
  196. % atlas_name = 'combined_inflammation_regions';
  197. % atlas_name = 'combined_TSPO';
  198. % atlas_mat = 'pet_trc-DPA714_combinedTSPO'; % lixin May26 2025
  199. % atlas_filename = fullfile(secondlevelpetmaskdir,[atlas_name '.nii']);
  200. % atlas_mat = fullfile(secondlevelpetmaskdir,[atlas_mat '.mat']); % lixin May26 2025
  201. % load(atlas_mat);
  202. % SPECIFY BASE NAME FOR THE OUTPUT FILES
  203. % we will extend the name with the name of the model and write as an excel file)
  204. outputfile_excel_region_based = fullfile(secondlevelpetresultsdir,['results_' infostring_tracer '_' atlas_name '_VOIS']);
  205. % SET OPTIONS FOR INTERSECTING WITH GRAY MATTER
  206. % if you want to intersect the VOI region with a subject specific GM or WM map, you need to specify the variables below
  207. % the same will be done for the parametric image with Logan_input in which case the voxels withing GM or WM after thresholding these maps will be calculated.
  208. intersect_GM = 0;
  209. intersect_WM = 0;
  210. GM_CUTOFF = 0.3;
  211. WM_CUTOFF = 0.3;
  212. % SET SMOOTHING KERNEL FOR VOXEL-BASED PARAMETRIC LOGAN IMAGES
  213. additional_smooth_parametric = 6; % kernel size in mm; isotropic Gaussian 3D smoothing; additional smoothing for a voxel based analysis. If GM of WM intersection is selected, smoothing is within this mask
  214. % SET NUMBER OF PARALLEL PROCESSES
  215. nr_parpool = 12; % LaBGAS server default
  216. % nr_parpool = 20;
  217. %+++++++++++++++ DO NOT CHANGE BELOW THIS LINE ++++++++++++++++++++++++++++
  218. %% SETTINGS
  219. %---------------------- settings ------------------------------------------
  220. min_number_voxels = 25; % minimum number of voxels in the parcel that are used for the calculation of the TAC.
  221. % we will use a multigrid search for the optimal parameters for the rate
  222. % constants for each model. Keep in mind that you have
  223. % nr_starting_values_per_dimension^4 number of starting values for a model
  224. % with 4 rate constants that you vary and
  225. % nr_starting_values_per_dimension^6 for a model with 6 parameters that you
  226. % would like to vary.
  227. % the time for the fitting is roughly proportional to the number of
  228. % starting values.
  229. % the starting value for Vb is fixed but it will be fitted.
  230. Vb0 = 0.05;
  231. nr_starting_values_per_dimension = 3;
  232. model_list = {
  233. 'Logan_input'
  234. '2T4k'
  235. '2T4k_Vb'
  236. '2T4k_vasc1k'
  237. '2T4k_vasc2k'
  238. };
  239. logan_start_time = 31; % in min (ref Van Weehaeghe et al. J Nucl Med. 2020 Apr;61(4):604-607)
  240. % initial values Hill function
  241. p0_hill = [50 -1]; % see LCN_calc_intact_tracer_hill for details
  242. % boundaries for the models with initial conditions
  243. k0_2T4k_lower_bound = [0.001 0.001 0.001 0.001];
  244. k0_2T4k_upper_bound = [1 1 1 1];
  245. k0_2T4k_Vb_lower_bound = [0.001 0.001 0.001 0.001 0.001];
  246. k0_2T4k_Vb_upper_bound = [1 1 1 1 1];
  247. k0_2T4k_vasc1k_lower_bound = [0.001 0.001 0.001 0.001 0.001 0.001];
  248. k0_2T4k_vasc1k_upper_bound = [1 1 1 1 1 1];
  249. k0_2T4k_vasc2k_lower_bound = [0.001 0.001 0.001 0.001 0.001 0.001 0.001];
  250. k0_2T4k_vasc2k_upper_bound = [1 1 1 1 1 1 1];
  251. nr_params_Logan_input = 2;
  252. nr_params_2T4k = 4;
  253. nr_params_2T4k_Vb = 5;
  254. nr_2T4k_vasc1k = 6;
  255. nr_2T4k_vasc2k = 7;
  256. options = optimoptions('fmincon','Display','off');
  257. STEP = 0.01; % step size for the calculation of integrals in min
  258. % CALC_OPTION: parameter determing the way we calculate the output of a
  259. % model.
  260. % 1 - the model is calculated as the integral of the output concentration
  261. % devided by the frameduration.
  262. % 2 - the model is calculated at the midscantime.
  263. CALC_OPTION = 2;
  264. window_size = 0; % for temporal median filtering
  265. thalf_F18 = 1.82871*60; % half life in min of 18F (REF: García-Toraño E, Medina VP, Ibarra MR. The half-life of 18F. Appl Radiat Isot. (2010) 68(7-8):1561-5)
  266. %--------------------------------------------------------------------------
  267. curdir = pwd;
  268. % determine the path of the prior data of SPM
  269. tmp = which('spm.m');
  270. [spm_pth,~,~] = fileparts(tmp);
  271. spm_pth_priors = fullfile(spm_pth,'tpm');
  272. % define the brain mask
  273. brain_mask_file = fullfile(spm_pth_priors,'mask_ICV.nii');
  274. nr_subjects = size(SUBJECTS,1);
  275. nr_models = size(model_list,1);
  276. %% READ ATLAS PARCELS
  277. %--------------------------------------------------------------------------
  278. if exist('atlas_filename','var') == 1 && ~isempty(atlas_filename) == 1
  279. % read atlas
  280. [atlas_orig,Vatlas_orig] = LCN12_read_image(atlas_filename);
  281. atlas_orig = round(atlas_orig);
  282. parcel_values = setdiff(unique(atlas_orig(:)),0); % assuming 0 is background
  283. % check if there is a .m file with the same name as the atlas
  284. % with the VOIdetails such as the name
  285. [pth,name,ext] = fileparts(atlas_filename);
  286. if exist(fullfile(pth,[name '.m']),'file') == 2
  287. % execute this m-file
  288. curdir = pwd;
  289. cd(pth);
  290. eval(name); % now VOIdetails is known, a n x 2 cell array with each row the value of a parcel in the atlas and the corresponding parcel name
  291. cd(curdir);
  292. parcel_values_atlas = cell2mat(VOIdetails(:,1));
  293. parcel_names = VOIdetails(:,2);
  294. else
  295. parcel_values_atlas = parcel_values;
  296. try
  297. parcel_names = atlas.labels;
  298. catch
  299. parcel_names = roi_atlas.labels;
  300. end
  301. % parcel_names = num2str(parcel_values);
  302. end
  303. nr_VOIS = length(parcel_values);
  304. % initialize output
  305. % varNames = cell(1,nr_VOIS+1);
  306. % for voi = 1:nr_VOIS
  307. % index_value = find(parcel_values_atlas == parcel_values(voi));
  308. % varNames(1,voi+1) = {[num2str(parcel_values(voi)) '-' char(parcel_names(index_value,:))]};
  309. % end
  310. else
  311. fprintf('You need to define an atlas \n');
  312. return;
  313. end
  314. %% INITIALIZE OUTPUT
  315. %--------------------------------------------------------------------------
  316. % PARAMETERS FOR EACH MODEL
  317. sz = [nr_subjects nr_VOIS+1];
  318. varNames = [{'subject'} (parcel_names)]; % lixin may26 2025
  319. varTypes(1,1) = {'string'};
  320. varTypes(1,2:nr_VOIS+1) = {'double'};
  321. results_number_voxels_VOI = table('Size',sz,'VariableTypes',varTypes,'VariableNames',varNames);
  322. for m = 1:nr_models
  323. modelname = model_list{m,1};
  324. if strcmp(modelname,'Logan_input')
  325. results_region_based_Logan_input_DV = table('Size',sz,'VariableTypes',varTypes,'VariableNames',varNames);
  326. results_region_based_Logan_input_error = table('Size',sz,'VariableTypes',varTypes,'VariableNames',varNames);
  327. end
  328. if strcmp(modelname,'2T4k')
  329. results_region_based_2T4k_K1 = table('Size',sz,'VariableTypes',varTypes,'VariableNames',varNames);
  330. results_region_based_2T4k_k2 = table('Size',sz,'VariableTypes',varTypes,'VariableNames',varNames);
  331. results_region_based_2T4k_k3 = table('Size',sz,'VariableTypes',varTypes,'VariableNames',varNames);
  332. results_region_based_2T4k_k4 = table('Size',sz,'VariableTypes',varTypes,'VariableNames',varNames);
  333. results_region_based_2T4k_DV = table('Size',sz,'VariableTypes',varTypes,'VariableNames',varNames);
  334. results_region_based_2T4k_error = table('Size',sz,'VariableTypes',varTypes,'VariableNames',varNames);
  335. end
  336. if strcmp(modelname,'2T4k_Vb')
  337. results_region_based_2T4k_Vb_K1 = table('Size',sz,'VariableTypes',varTypes,'VariableNames',varNames);
  338. results_region_based_2T4k_Vb_k2 = table('Size',sz,'VariableTypes',varTypes,'VariableNames',varNames);
  339. results_region_based_2T4k_Vb_k3 = table('Size',sz,'VariableTypes',varTypes,'VariableNames',varNames);
  340. results_region_based_2T4k_Vb_k4 = table('Size',sz,'VariableTypes',varTypes,'VariableNames',varNames);
  341. results_region_based_2T4k_Vb_Vb = table('Size',sz,'VariableTypes',varTypes,'VariableNames',varNames);
  342. results_region_based_2T4k_Vb_DV = table('Size',sz,'VariableTypes',varTypes,'VariableNames',varNames);
  343. results_region_based_2T4k_Vb_error = table('Size',sz,'VariableTypes',varTypes,'VariableNames',varNames);
  344. end
  345. if strcmp(modelname,'2T4k_vasc1k')
  346. results_region_based_2T4k_vasc1k_K1 = table('Size',sz,'VariableTypes',varTypes,'VariableNames',varNames);
  347. results_region_based_2T4k_vasc1k_k2 = table('Size',sz,'VariableTypes',varTypes,'VariableNames',varNames);
  348. results_region_based_2T4k_vasc1k_k3 = table('Size',sz,'VariableTypes',varTypes,'VariableNames',varNames);
  349. results_region_based_2T4k_vasc1k_k4 = table('Size',sz,'VariableTypes',varTypes,'VariableNames',varNames);
  350. results_region_based_2T4k_vasc1k_Vb = table('Size',sz,'VariableTypes',varTypes,'VariableNames',varNames);
  351. results_region_based_2T4k_vasc1k_K1v = table('Size',sz,'VariableTypes',varTypes,'VariableNames',varNames);
  352. results_region_based_2T4k_vasc1k_DV = table('Size',sz,'VariableTypes',varTypes,'VariableNames',varNames);
  353. results_region_based_2T4k_vasc1k_error = table('Size',sz,'VariableTypes',varTypes,'VariableNames',varNames);
  354. end
  355. if strcmp(modelname,'2T4k_vasc2k')
  356. results_region_based_2T4k_vasc2k_K1 = table('Size',sz,'VariableTypes',varTypes,'VariableNames',varNames);
  357. results_region_based_2T4k_vasc2k_k2 = table('Size',sz,'VariableTypes',varTypes,'VariableNames',varNames);
  358. results_region_based_2T4k_vasc2k_k3 = table('Size',sz,'VariableTypes',varTypes,'VariableNames',varNames);
  359. results_region_based_2T4k_vasc2k_k4 = table('Size',sz,'VariableTypes',varTypes,'VariableNames',varNames);
  360. results_region_based_2T4k_vasc2k_Vb = table('Size',sz,'VariableTypes',varTypes,'VariableNames',varNames);
  361. results_region_based_2T4k_vasc2k_K1v = table('Size',sz,'VariableTypes',varTypes,'VariableNames',varNames);
  362. results_region_based_2T4k_vasc2k_k2v = table('Size',sz,'VariableTypes',varTypes,'VariableNames',varNames);
  363. results_region_based_2T4k_vasc2k_DV = table('Size',sz,'VariableTypes',varTypes,'VariableNames',varNames);
  364. results_region_based_2T4k_vasc2k_error = table('Size',sz,'VariableTypes',varTypes,'VariableNames',varNames);
  365. end
  366. end
  367. % FIT STATISTICS FOR ALL MODELS
  368. sz2 = [nr_subjects*4 nr_VOIS+2];
  369. varNames2 = [{'subject'} {'method'} (parcel_names)]; % lukasvo sept 22 2025
  370. varTypes2 = cell(1, nr_VOIS + 2);
  371. varTypes2(1:2) = {'string', 'string'};
  372. varTypes2(3:end) = repmat({'double'}, 1, nr_VOIS);
  373. results_region_based_AIC = table('Size', sz2, 'VariableTypes', varTypes2, 'VariableNames', varNames2);
  374. results_region_based_SC = table('Size', sz2, 'VariableTypes', varTypes2, 'VariableNames', varNames2);
  375. %% DETERMINING THE GRID OF STARTING VALUES WITHIN THE SEARCH SPACE
  376. %--------------------------------------------------------------------------
  377. for m = 1:nr_models
  378. modelname = model_list{m,1};
  379. if strcmp(modelname,'2T4k')
  380. k0_2T4k_all_values = zeros(nr_starting_values_per_dimension^4,4);
  381. counter = 0;
  382. for d1 = 1:nr_starting_values_per_dimension
  383. val1 = k0_2T4k_lower_bound(1) + d1*(k0_2T4k_upper_bound(1) - k0_2T4k_lower_bound(1))/(nr_starting_values_per_dimension+1);
  384. for d2 = 1:nr_starting_values_per_dimension
  385. val2 = k0_2T4k_lower_bound(2) + d2*(k0_2T4k_upper_bound(2) - k0_2T4k_lower_bound(2))/(nr_starting_values_per_dimension+1);
  386. for d3 = 1:nr_starting_values_per_dimension
  387. val3 = k0_2T4k_lower_bound(3) + d3*(k0_2T4k_upper_bound(3) - k0_2T4k_lower_bound(3))/(nr_starting_values_per_dimension+1);
  388. for d4 = 1:nr_starting_values_per_dimension
  389. val4 = k0_2T4k_lower_bound(4) + d4*(k0_2T4k_upper_bound(4) - k0_2T4k_lower_bound(4))/(nr_starting_values_per_dimension+1);
  390. counter = counter + 1;
  391. k0_2T4k_all_values(counter,:) = [val1 val2 val3 val4];
  392. end
  393. end
  394. end
  395. end
  396. nr_k0_2T4k = size(k0_2T4k_all_values,1);
  397. end
  398. if strcmp(modelname,'2T4k_Vb')
  399. k0_2T4k_Vb_all_values = zeros(nr_starting_values_per_dimension^4,5);
  400. counter = 0;
  401. val5 = Vb0;
  402. for d1 = 1:nr_starting_values_per_dimension
  403. val1 = k0_2T4k_Vb_lower_bound(1) + d1*(k0_2T4k_Vb_upper_bound(1) - k0_2T4k_Vb_lower_bound(1))/(nr_starting_values_per_dimension+1);
  404. for d2 = 1:nr_starting_values_per_dimension
  405. val2 = k0_2T4k_Vb_lower_bound(2) + d2*(k0_2T4k_Vb_upper_bound(2) - k0_2T4k_Vb_lower_bound(2))/(nr_starting_values_per_dimension+1);
  406. for d3 = 1:nr_starting_values_per_dimension
  407. val3 = k0_2T4k_Vb_lower_bound(3) + d3*(k0_2T4k_Vb_upper_bound(3) - k0_2T4k_Vb_lower_bound(3))/(nr_starting_values_per_dimension+1);
  408. for d4 = 1:nr_starting_values_per_dimension
  409. val4 = k0_2T4k_Vb_lower_bound(4) + d4*(k0_2T4k_Vb_upper_bound(4) - k0_2T4k_Vb_lower_bound(4))/(nr_starting_values_per_dimension+1);
  410. counter = counter + 1;
  411. k0_2T4k_Vb_all_values(counter,:) = [val1 val2 val3 val4 val5];
  412. end
  413. end
  414. end
  415. end
  416. nr_k0_2T4k_Vb = size(k0_2T4k_Vb_all_values,1);
  417. end
  418. if strcmp(modelname,'2T4k_vasc1k')
  419. k0_2T4k_vasc1k_all_values = zeros(nr_starting_values_per_dimension^5,6);
  420. counter = 0;
  421. val5 = Vb0;
  422. for d1 = 1:nr_starting_values_per_dimension
  423. val1 = k0_2T4k_vasc1k_lower_bound(1) + d1*(k0_2T4k_vasc1k_upper_bound(1) - k0_2T4k_vasc1k_lower_bound(1))/(nr_starting_values_per_dimension+1);
  424. for d2 = 1:nr_starting_values_per_dimension
  425. val2 = k0_2T4k_vasc1k_lower_bound(2) + d2*(k0_2T4k_vasc1k_upper_bound(2) - k0_2T4k_vasc1k_lower_bound(2))/(nr_starting_values_per_dimension+1);
  426. for d3 = 1:nr_starting_values_per_dimension
  427. val3 = k0_2T4k_vasc1k_lower_bound(3) + d3*(k0_2T4k_vasc1k_upper_bound(3) - k0_2T4k_vasc1k_lower_bound(3))/(nr_starting_values_per_dimension+1);
  428. for d4 = 1:nr_starting_values_per_dimension
  429. val4 = k0_2T4k_vasc1k_lower_bound(4) + d4*(k0_2T4k_vasc1k_upper_bound(4) - k0_2T4k_vasc1k_lower_bound(4))/(nr_starting_values_per_dimension+1);
  430. for d6 = 1:nr_starting_values_per_dimension
  431. val6 = k0_2T4k_vasc1k_lower_bound(6) + d4*(k0_2T4k_vasc1k_upper_bound(6) - k0_2T4k_vasc1k_lower_bound(6))/(nr_starting_values_per_dimension+1);
  432. counter = counter + 1;
  433. k0_2T4k_vasc1k_all_values(counter,:) = [val1 val2 val3 val4 val5 val6];
  434. end
  435. end
  436. end
  437. end
  438. end
  439. nr_k0_2T4k_vasc1k = size(k0_2T4k_vasc1k_all_values,1);
  440. end
  441. if strcmp(modelname,'2T4k_vasc2k')
  442. k0_2T4k_vasc2k_all_values = zeros(nr_starting_values_per_dimension^6,7);
  443. counter = 0;
  444. val5 = Vb0;
  445. for d1 = 1:nr_starting_values_per_dimension
  446. val1 = k0_2T4k_vasc2k_lower_bound(1) + d1*(k0_2T4k_vasc2k_upper_bound(1) - k0_2T4k_vasc2k_lower_bound(1))/(nr_starting_values_per_dimension+1);
  447. for d2 = 1:nr_starting_values_per_dimension
  448. val2 = k0_2T4k_vasc2k_lower_bound(2) + d2*(k0_2T4k_vasc2k_upper_bound(2) - k0_2T4k_vasc2k_lower_bound(2))/(nr_starting_values_per_dimension+1);
  449. for d3 = 1:nr_starting_values_per_dimension
  450. val3 = k0_2T4k_vasc2k_lower_bound(3) + d3*(k0_2T4k_vasc2k_upper_bound(3) - k0_2T4k_vasc2k_lower_bound(3))/(nr_starting_values_per_dimension+1);
  451. for d4 = 1:nr_starting_values_per_dimension
  452. val4 = k0_2T4k_vasc2k_lower_bound(4) + d4*(k0_2T4k_vasc2k_upper_bound(4) - k0_2T4k_vasc2k_lower_bound(4))/(nr_starting_values_per_dimension+1);
  453. for d6 = 1:nr_starting_values_per_dimension
  454. val6 = k0_2T4k_vasc2k_lower_bound(6) + d4*(k0_2T4k_vasc2k_upper_bound(6) - k0_2T4k_vasc2k_lower_bound(6))/(nr_starting_values_per_dimension+1);
  455. for d7 = 1:nr_starting_values_per_dimension
  456. val7 = k0_2T4k_vasc2k_lower_bound(7) + d4*(k0_2T4k_vasc2k_upper_bound(7) - k0_2T4k_vasc2k_lower_bound(7))/(nr_starting_values_per_dimension+1);
  457. counter = counter + 1;
  458. k0_2T4k_vasc2k_all_values(counter,:) = [val1 val2 val3 val4 val5 val6 val7];
  459. end
  460. end
  461. end
  462. end
  463. end
  464. end
  465. nr_k0_2T4k_vasc2k = size(k0_2T4k_vasc2k_all_values,1);
  466. end
  467. end
  468. %% LOOP OVER SUBJECTS
  469. %--------------------------------------------------------------------------
  470. parpool(nr_parpool);
  471. for subj = 1:nr_subjects
  472. % PREP WORK
  473. clear subjectdir subjectname dir_anat dir_pet dir_deriv* dir_firstlevel dir_tmp dir_anat2 DV_Logan
  474. clear tmp_frames frames_timing nr_frames acqtimes FRAMEDURATION MIDSCANTIMES WEIGHTS_PET
  475. clear name_logfile fid go go_GM go_WM go_CSF go_PET go_frames go_input go_metab Vref Vref_tmp
  476. subjectname = SUBJECTS{subj};
  477. subjectdir = fullfile(maindir,subjectname);
  478. if ~isempty(sessiondir)
  479. dir_pet = fullfile(fullfile(subjectdir,sessiondir),['pet_' infostring_tracer]);
  480. dir_deriv = fullfile(derivpetdir,subjectname,sessiondir);
  481. dir_deriv_tmp = fullfile(dir_deriv,'tmp');
  482. dir_deriv_anat2 = fullfile(dir_deriv,'anat');
  483. dir_firstlevel = fullfile(firstlevelpetdir,subjectname,sessiondir);
  484. if ~exist(dir_firstlevel,'dir')
  485. mkdir(dir_firstlevel);
  486. end
  487. else
  488. dir_pet = fullfile(subjectdir,['pet_' infostring_tracer]);
  489. dir_deriv = fullfile(derivpetdir,subjectname);
  490. dir_deriv_tmp = fullfile(dir_deriv,'tmp');
  491. dir_deriv_anat2 = fullfile(dir_deriv,'anat');
  492. dir_firstlevel = fullfile(firstlevelpetdir,subjectname);
  493. if ~exist(dir_firstlevel,'dir')
  494. mkdir(dir_firstlevel);
  495. end
  496. end
  497. if save_figures == 1
  498. dir_figures = fullfile(dir_deriv,'figures');
  499. if exist(dir_figures,'dir') ~= 7
  500. mkdir(dir_figures);
  501. end
  502. end
  503. fprintf('working on subject %s \n',subjectname);
  504. name_logfile = fullfile(dir_deriv,'LCN12_PET_TSPO_DPA714_log.txt');
  505. fid = fopen(name_logfile,'a+');
  506. fprintf(fid,'subject = %s\n',subjectname);
  507. fprintf(fid,'LCN12_PET_TSPO_DPA714_compare_models.m \n');
  508. fprintf(fid,'%c','-'*ones(1,30));
  509. fprintf(fid,'\n');
  510. fprintf(fid,'Processing started at %s\n',datetime('now'));
  511. fprintf(fid,'\n');
  512. fprintf(fid,'Settings\n');
  513. fprintf(fid,'brain_mask_file = %s\n',brain_mask_file);
  514. fprintf(fid,'figures_on = %i\n',figures_on);
  515. fprintf(fid,'save_figures = %i\n',save_figures);
  516. fprintf(fid,'atlas_filename = %s\n',atlas_filename);
  517. if exist('intersect_GM','var') == 1
  518. fprintf(fid,'intersect_GM = %i\n',intersect_GM);
  519. else
  520. fprintf(fid,'intersect_GM = not defined \n');
  521. end
  522. if exist('intersect_WM','var') == 1
  523. fprintf(fid,'intersect_WM = %i\n',intersect_WM);
  524. else
  525. fprintf(fid,'intersect_WM = not defined \n');
  526. end
  527. if exist('GM_CUTOFF','var') == 1
  528. fprintf(fid,'GM_CUTOFF = %4,2f\n',GM_CUTOFF);
  529. else
  530. fprintf(fid,'GM_CUTOFF = not defined \n');
  531. end
  532. if exist('WM_CUTOFF','var') == 1
  533. fprintf(fid,'WM_CUTOFF = %4.2f\n',WM_CUTOFF);
  534. else
  535. fprintf(fid,'WM_CUTOFF = not defined \n');
  536. end
  537. fprintf(fid,'p0_hill = [%4.2f %4.2f] \n',p0_hill(1),p0_hill(2));
  538. for m = 1:nr_models
  539. modelname = model_list{m,1};
  540. if strcmp(modelname,'Logan_input')
  541. fprintf(fid,'logan_start_time (min) = %i \n',logan_start_time);
  542. end
  543. if strcmp(modelname,'2T4k')
  544. fprintf(fid,'k0_2T4k_lower_bound = [%4.3f %4.3f %4.3f %4.3f %4.3f] \n',k0_2T4k_lower_bound(1),k0_2T4k_lower_bound(2),k0_2T4k_lower_bound(3),k0_2T4k_lower_bound(4));
  545. fprintf(fid,'k0_2T4k_upper_bound = [%4.3f %4.3f %4.3f %4.3f %4.3f] \n',k0_2T4k_upper_bound(1),k0_2T4k_upper_bound(2),k0_2T4k_upper_bound(3),k0_2T4k_upper_bound(4));
  546. end
  547. if strcmp(modelname,'2T4k_Vb')
  548. fprintf(fid,'k0_2T4k_Vb_lower_bound = [%4.3f %4.3f %4.3f %4.3f %4.3f] \n',k0_2T4k_Vb_lower_bound(1),k0_2T4k_Vb_lower_bound(2),k0_2T4k_Vb_lower_bound(3),k0_2T4k_Vb_lower_bound(4),k0_2T4k_Vb_lower_bound(5));
  549. fprintf(fid,'k0_2T4k_Vb_upper_bound = [%4.3f %4.3f %4.3f %4.3f %4.3f] \n',k0_2T4k_Vb_upper_bound(1),k0_2T4k_Vb_upper_bound(2),k0_2T4k_Vb_upper_bound(3),k0_2T4k_Vb_upper_bound(4),k0_2T4k_Vb_upper_bound(5));
  550. end
  551. if strcmp(modelname,'2T4k_vasc1k')
  552. fprintf(fid,'k0_2T4k_vasc1k_lower_bound = [%4.3f %4.3f %4.3f %4.3f %4.3f %4.3f] \n',k0_2T4k_vasc1k_lower_bound(1),k0_2T4k_vasc1k_lower_bound(2),k0_2T4k_vasc1k_lower_bound(3),k0_2T4k_vasc1k_lower_bound(4),k0_2T4k_vasc1k_lower_bound(5),k0_2T4k_vasc1k_lower_bound(6));
  553. fprintf(fid,'k0_2T4k_vasc1k_upper_bound = [%4.3f %4.3f %4.3f %4.3f %4.3f %4.3f] \n',k0_2T4k_vasc1k_upper_bound(1),k0_2T4k_vasc1k_upper_bound(2),k0_2T4k_vasc1k_upper_bound(3),k0_2T4k_vasc1k_upper_bound(4),k0_2T4k_vasc1k_upper_bound(5),k0_2T4k_vasc1k_upper_bound(6));
  554. end
  555. if strcmp(modelname,'2T4k_vasc2k')
  556. fprintf(fid,'k0_2T4k_vasc2k_lower_bound = [%4.3f %4.3f %4.3f %4.3f %4.3f %4.3f %4.3f] \n',k0_2T4k_vasc2k_lower_bound(1),k0_2T4k_vasc2k_lower_bound(2),k0_2T4k_vasc2k_lower_bound(3),k0_2T4k_vasc2k_lower_bound(4),k0_2T4k_vasc2k_lower_bound(5),k0_2T4k_vasc2k_lower_bound(6),k0_2T4k_vasc2k_lower_bound(7));
  557. fprintf(fid,'k0_2T4k_vasc2k_upper_bound = [%4.3f %4.3f %4.3f %4.3f %4.3f %4.3f %4.3f] \n',k0_2T4k_vasc2k_upper_bound(1),k0_2T4k_vasc2k_upper_bound(2),k0_2T4k_vasc2k_upper_bound(3),k0_2T4k_vasc2k_upper_bound(4),k0_2T4k_vasc2k_upper_bound(5),k0_2T4k_vasc2k_upper_bound(6),k0_2T4k_vasc2k_upper_bound(7));
  558. end
  559. end
  560. % CHECK IF WE CAN FIND ALL INPUT DATA IN MNI SPACE
  561. [filename_GM,go_GM] = LCN_check_filename(dir_deriv_anat2,['wc1' subjectname '*.nii']);
  562. [filename_WM,go_WM] = LCN_check_filename(dir_deriv_anat2,['wc2' subjectname '*.nii']);
  563. [filename_CSF,go_CSF] = LCN_check_filename(dir_deriv_anat2,['wc3' subjectname '*.nii']);
  564. [filename_wPET,go_PET] = LCN_check_filename(dir_deriv,['w' subjectname '*_' infostring_tracer '*_' infostring_PET '.nii']);
  565. [frame_definition_file,go_frames] = LCN_check_filename(dir_pet,[subjectname '_*' infostring_tracer '_' infostring_PET '_' infostring_frames '.m']);
  566. [input_file,go_input] = LCN_check_filename(dir_pet,[subjectname '_*' infostring_tracer '_' infostring_input '.m']);
  567. [metab_file,go_metab] = LCN_check_filename(dir_pet,[subjectname '_*' infostring_tracer '_' infostring_metab '.m']);
  568. % READ PLASMA AND BLOOD DATA, PERFORM CALCULATIONS, AND ANALYSE DATA
  569. if go_frames == 1 % frame definition file found
  570. % read the frame definition file
  571. fprintf(fid,'Timing file: %s\n',frame_definition_file);
  572. copyfile(frame_definition_file,'tmp_frames.m');
  573. tmp_frames; % the variable frames_timing is now known
  574. delete('tmp_frames.m');
  575. nr_frames = size(frames_timing,1);
  576. % calculate midscan times (in minutes)
  577. acqtimes = frames_timing(:,1:2)/60; % in minutes
  578. FRAMEDURATION = acqtimes(:,2)-acqtimes(:,1);
  579. MIDSCANTIMES = acqtimes(:,1) + FRAMEDURATION/2;
  580. else
  581. fprintf(fid,'frame definition file not found for subject %s \n',subjectname);
  582. continue;
  583. end
  584. if go_input*go_metab == 1
  585. clear ref_time scanner_time
  586. % read the input data and metab data
  587. fprintf(fid,'Input file: %s\n',input_file);
  588. copyfile(input_file,'tmp_input_file.m');
  589. tmp_input_file; % the variable input and calibrationfactor_wellcounter are now known
  590. delete('tmp_input_file.m');
  591. fprintf(fid,'Metab file: %s\n',metab_file);
  592. copyfile(metab_file,'tmp_metab_file.m');
  593. tmp_metab_file; % the variable data_metab is now known
  594. delete('tmp_metab_file.m');
  595. % analyse the metab data
  596. TIME_METAB = data_metab(:,1)/60; % time p.i. in min
  597. FRACTION_INTACT_TRACER = data_metab(:,2)/100; % fraction intact tracer
  598. if size(data_metab,2) == 3
  599. WEIGHTS_METAB = data_metab(:,3);
  600. else
  601. WEIGHTS_METAB = ones(size(data_metab,1),1);
  602. end
  603. % normalize WEIGHTS
  604. WEIGHTS_METAB = WEIGHTS_METAB/sum(WEIGHTS_METAB);
  605. % apply a hill fit for the metabolites
  606. % nr_params_hill = length(p0_hill);
  607. % nr_samples = length(TIME_METAB);
  608. clear pfit res intact_fine
  609. % fit hill model
  610. cost_function = @(p) norm(WEIGHTS_METAB .* (LCN_calc_intact_tracer_hill(p,TIME_METAB)' - FRACTION_INTACT_TRACER));
  611. [pfit, error] = fminsearch(cost_function, p0_hill);
  612. if figures_on == 1 || save_figures == 1
  613. close('all');
  614. hfig1 = figure(1);
  615. set(hfig1,'Name',subjectname);
  616. plot(TIME_METAB,FRACTION_INTACT_TRACER,'o')
  617. axis([0 1.1*max(TIME_METAB) 0 1])
  618. hold on
  619. fine_time = (0:0.01:max(TIME_METAB))';
  620. intact_fine = LCN_calc_intact_tracer_hill(pfit,fine_time);
  621. plot(fine_time,intact_fine)
  622. title('hill');
  623. xlabel('time (min)')
  624. ylabel('fraction intact tracer')
  625. if save_figures == 1
  626. cd(dir_figures);
  627. saveas(hfig1,['fig_metab_' subjectname '.fig']);
  628. else
  629. pause
  630. end
  631. end
  632. % analyse the input data (plasma and blood)
  633. % if the variables ref_time and scanner_time exist, we need to
  634. % correct for decay between measurement of samples and start scan.
  635. % if they are not available, it means that the data are not yet
  636. % corrected for this time difference and it will be done here.
  637. if exist('ref_time','var') == 1 && exist('scanner_time','var') == 1
  638. % correct blood data for decay between start scan and start measurement and well counter
  639. dt = minutes(duration(datetime(ref_time)-datetime(scanner_time),'Format','s'));
  640. decay_factor = exp(log(2)*dt/thalf_F18);
  641. input(:,2) = input(:,2).*decay_factor;
  642. input(:,3) = input(:,3).*decay_factor;
  643. end
  644. % calculate corrected inputcurve
  645. time_input = input(:,1)/60; % time in min
  646. [correction] = LCN_calc_intact_tracer_hill(pfit,time_input);
  647. uncor_input = calibrationfactor_wellcounter.*input(:,2)/(60*1000); % in kBq/ml
  648. corrected_input = calibrationfactor_wellcounter.*correction.*input(:,2)/(60*1000); % in kBq/ml
  649. uncor_blood = calibrationfactor_wellcounter.*input(:,3)/(60*1000); % in kBq/ml
  650. TIME = [0; time_input];
  651. FINETIMES = (0:STEP:max(TIME))';
  652. CA = [0; corrected_input];
  653. CA_WB = [0; uncor_blood];
  654. CA_FINETIMES = interp1q(TIME,CA,FINETIMES);
  655. CA_MIDSCANTIMES = interp1q(TIME,CA,MIDSCANTIMES);
  656. CA_WB_FINETIMES = interp1q(TIME,CA_WB,FINETIMES);
  657. if figures_on == 1 || save_figures == 1
  658. hfig2 = figure(2);
  659. set(hfig2,'Name',subjectname);
  660. subplot(1,2,1);
  661. plot(time_input,uncor_input,'o');
  662. hold on
  663. plot(time_input,corrected_input);
  664. axis([0 1.1*max(time_input) 0 max(uncor_input)]);
  665. title('plasma input function');
  666. xlabel('time (min)');
  667. ylabel('kBq/ml');
  668. subplot(1,2,2);
  669. plot(time_input,uncor_blood,'*r');
  670. axis([0 1.1*max(time_input) 0 max(uncor_blood)]);
  671. title('whole blood');
  672. xlabel('time (min)');
  673. ylabel('kBq/ml');
  674. if save_figures == 1
  675. cd(dir_figures);
  676. saveas(hfig2,['fig_input_' subjectname '.fig']);
  677. else
  678. pause
  679. end
  680. end
  681. end
  682. % READ BRAIN DATA
  683. if go_PET == 1 % dynamic data are found
  684. % reading data in MNI space
  685. fprintf('reading data of subject %s',subjectname);
  686. fprintf(fid,'\n');
  687. fprintf(fid,'Reading data in MNI space started: %s \n',datetime('now'));
  688. if pet_space_reference
  689. Vref_tmp = spm_vol(filename_wPET);
  690. Vref = Vref_tmp(1);
  691. % read dynamic data
  692. dydata = zeros(Vref.dim(1),Vref.dim(2),Vref.dim(3),nr_frames);
  693. for frame = 1:nr_frames
  694. clear tmp
  695. tmp = LCN12_read_image([filename_wPET ',' num2str(frame)],Vref);
  696. dydata(:,:,:,frame) = tmp/1000; %in kBq/ml
  697. end
  698. else
  699. atlas = atlas_orig;
  700. Vref = Vatlas_orig;
  701. dydata = zeros(Vref.dim(1),Vref.dim(2),Vref.dim(3),nr_frames);
  702. for frame = 1:nr_frames
  703. clear tmp
  704. tmp = LCN12_read_image([filename_wPET ',' num2str(frame)],Vref);
  705. dydata(:,:,:,frame) = tmp/1000; %in kBq/ml
  706. end
  707. end
  708. % load the file excluded_frames
  709. [filename_excluded_frames,~] = LCN_check_filename(dir_deriv,'excluded_frames_*pet.mat');
  710. load(filename_excluded_frames); % now the variable excluded_frames is know
  711. frames_ok = setdiff(1:nr_frames,excluded_frames)';
  712. idx_frames = MIDSCANTIMES > logan_start_time;
  713. if size(frames_ok,1) < (size(FRAMEDURATION,1) - sum(idx_frames) + 2) % we need at least 3 points to fit the Logan regression line
  714. fprintf('\nWARNING: all frames after logan start time %d are excluded based on head motion, Logan cannot be fit - skipping subject %s\n', logan_start_time, subjectname);
  715. continue
  716. end
  717. % read brain mask in MNI
  718. fprintf(fid,'brain mask: %s\n',brain_mask_file);
  719. brain_mask_img = LCN12_read_image(brain_mask_file,Vref);
  720. % determine masks
  721. brain_mask = (brain_mask_img > 0.5);
  722. % get the voxel size
  723. tmp = spm_imatrix(Vref.mat); % tmp(7:9) are the voxel sizes
  724. voxelsize_wPET = abs(tmp(7:9));
  725. else
  726. fprintf('Dynamic data of subject %s not found \n',subjectname);
  727. continue;
  728. end
  729. if go_GM*go_WM*go_CSF == 1
  730. % read segmentations
  731. fprintf(fid,'GM: %s\n',filename_GM);
  732. GMimg = LCN12_read_image(filename_GM,Vref);
  733. fprintf(fid,'WM: %s\n',filename_WM);
  734. WMimg = LCN12_read_image(filename_WM,Vref);
  735. fprintf(fid,'CSF: %s\n',filename_CSF);
  736. CSFimg = LCN12_read_image(filename_CSF,Vref);
  737. end
  738. fprintf('... done\n');
  739. fprintf(fid,'reading data ended at %s\n',datetime('now'));
  740. if figures_on == 1 || save_figures == 1
  741. hfig3 = figure(3);
  742. hfig4 = figure(4);
  743. end
  744. % INITIATE VARIABLES FOR MODEL (COMPARISON) RESULTS
  745. for m = 1:nr_models
  746. modelname = model_list{m,1};
  747. if strcmp(modelname,'Logan_input')
  748. results_region_based_Logan_input_DV(subj,1) = {subjectname};
  749. results_region_based_Logan_input_error(subj,1) = {subjectname};
  750. if save_parcelimgs
  751. atlas_Logan_input_DV = zeros(size(atlas_orig));
  752. atlas_Logan_input_error = zeros(size(atlas_orig));
  753. end
  754. end
  755. if strcmp(modelname,'2T4k')
  756. results_region_based_2T4k_K1(subj,1) = {subjectname};
  757. results_region_based_2T4k_k2(subj,1) = {subjectname};
  758. results_region_based_2T4k_k3(subj,1) = {subjectname};
  759. results_region_based_2T4k_k4(subj,1) = {subjectname};
  760. results_region_based_2T4k_DV(subj,1) = {subjectname};
  761. results_region_based_2T4k_error(subj,1) = {subjectname};
  762. if save_parcelimgs
  763. atlas_2T4k_K1 = zeros(size(atlas_orig));
  764. atlas_2T4k_k2 = zeros(size(atlas_orig));
  765. atlas_2T4k_k3 = zeros(size(atlas_orig));
  766. atlas_2T4k_k4 = zeros(size(atlas_orig));
  767. atlas_2T4k_DV = zeros(size(atlas_orig));
  768. atlas_2T4k_error = zeros(size(atlas_orig));
  769. end
  770. end
  771. if strcmp(modelname,'2T4k_Vb')
  772. results_region_based_2T4k_Vb_K1(subj,1) = {subjectname};
  773. results_region_based_2T4k_Vb_k2(subj,1) = {subjectname};
  774. results_region_based_2T4k_Vb_k3(subj,1) = {subjectname};
  775. results_region_based_2T4k_Vb_k4(subj,1) = {subjectname};
  776. results_region_based_2T4k_Vb_Vb(subj,1) = {subjectname};
  777. results_region_based_2T4k_Vb_DV(subj,1) = {subjectname};
  778. results_region_based_2T4k_Vb_error(subj,1) = {subjectname};
  779. if save_parcelimgs
  780. atlas_2T4k_Vb_K1 = zeros(size(atlas_orig));
  781. atlas_2T4k_Vb_k2 = zeros(size(atlas_orig));
  782. atlas_2T4k_Vb_k3 = zeros(size(atlas_orig));
  783. atlas_2T4k_Vb_k4 = zeros(size(atlas_orig));
  784. atlas_2T4k_Vb_Vb = zeros(size(atlas_orig));
  785. atlas_2T4k_Vb_DV = zeros(size(atlas_orig));
  786. atlas_2T4k_Vb_error = zeros(size(atlas_orig));
  787. end
  788. end
  789. if strcmp(modelname,'2T4k_vasc1k')
  790. results_region_based_2T4k_vasc1k_K1(subj,1) = {subjectname};
  791. results_region_based_2T4k_vasc1k_k2(subj,1) = {subjectname};
  792. results_region_based_2T4k_vasc1k_k3(subj,1) = {subjectname};
  793. results_region_based_2T4k_vasc1k_k4(subj,1) = {subjectname};
  794. results_region_based_2T4k_vasc1k_Vb(subj,1) = {subjectname};
  795. results_region_based_2T4k_vasc1k_K1v(subj,1) = {subjectname};
  796. results_region_based_2T4k_vasc1k_DV(subj,1) = {subjectname};
  797. results_region_based_2T4k_vasc1k_error(subj,1) = {subjectname};
  798. if save_parcelimgs
  799. atlas_2T4k_vasc1k_K1 = zeros(size(atlas_orig));
  800. atlas_2T4k_vasc1k_k2 = zeros(size(atlas_orig));
  801. atlas_2T4k_vasc1k_k3 = zeros(size(atlas_orig));
  802. atlas_2T4k_vasc1k_k4 = zeros(size(atlas_orig));
  803. atlas_2T4k_vasc1k_Vb = zeros(size(atlas_orig));
  804. atlas_2T4k_vasc1k_K1v = zeros(size(atlas_orig));
  805. atlas_2T4k_vasc1k_DV = zeros(size(atlas_orig));
  806. atlas_2T4k_vasc1k_error = zeros(size(atlas_orig));
  807. end
  808. end
  809. if strcmp(modelname,'2T4k_vasc2k')
  810. results_region_based_2T4k_vasc2k_K1(subj,1) = {subjectname};
  811. results_region_based_2T4k_vasc2k_k2(subj,1) = {subjectname};
  812. results_region_based_2T4k_vasc2k_k3(subj,1) = {subjectname};
  813. results_region_based_2T4k_vasc2k_k4(subj,1) = {subjectname};
  814. results_region_based_2T4k_vasc2k_Vb(subj,1) = {subjectname};
  815. results_region_based_2T4k_vasc2k_K1v(subj,1) = {subjectname};
  816. results_region_based_2T4k_vasc2k_k2v(subj,1) = {subjectname};
  817. results_region_based_2T4k_vasc2k_DV(subj,1) = {subjectname};
  818. results_region_based_2T4k_vasc2k_error(subj,1) = {subjectname};
  819. if save_parcelimgs
  820. atlas_2T4k_vasc2k_K1 = zeros(size(atlas_orig));
  821. atlas_2T4k_vasc2k_k2 = zeros(size(atlas_orig));
  822. atlas_2T4k_vasc2k_k3 = zeros(size(atlas_orig));
  823. atlas_2T4k_vasc2k_k4 = zeros(size(atlas_orig));
  824. atlas_2T4k_vasc2k_Vb = zeros(size(atlas_orig));
  825. atlas_2T4k_vasc2k_K1v = zeros(size(atlas_orig));
  826. atlas_2T4k_vasc2k_k2v = zeros(size(atlas_orig));
  827. atlas_2T4k_vasc2k_DV = zeros(size(atlas_orig));
  828. atlas_2T4k_vasc2k_error = zeros(size(atlas_orig));
  829. end
  830. end
  831. end
  832. results_number_voxels_VOI(subj,1) = {subjectname};
  833. results_region_based_AIC(4*(subj-1)+1,1) = {subjectname};
  834. results_region_based_SC(4*(subj-1)+1,1) = {subjectname};
  835. % READ ATLAS DATA
  836. if pet_space_reference == 1
  837. % read the atlas in the matrix of the subject
  838. atlas = LCN12_read_image(atlas_filename,Vref);
  839. % atlas contains non-integer values in voxels which are a mixture. We focus
  840. % only on voxels which are of one specific type
  841. % therefore, set the value of other voxels to 0
  842. atlas(mod(atlas,1) > 0) = 0;
  843. end
  844. % adapt weight of the frames
  845. WEIGHTS_PET = ones(length(MIDSCANTIMES),1);
  846. WEIGHTS_PET(excluded_frames) = 0;
  847. WEIGHTS_PET = WEIGHTS_PET./sum(WEIGHTS_PET);
  848. fprintf('atlas based analysis started at %s \n',datetime('now'));
  849. fprintf(fid,'atlas based analysis started at %s \n',datetime('now'));
  850. % LOOP OVER VOIS
  851. for voi = 1:nr_VOIS
  852. clear index_value VOIimg VOIname C_MEASURED
  853. index_value = find(parcel_values_atlas == parcel_values(voi));
  854. VOIname = parcel_names{1,index_value};
  855. fprintf(fid,'VOI %i: %s\n',index_value,VOIname);
  856. VOIimg = (atlas == parcel_values(voi));
  857. % intersect VOI with subject specific GM or WM
  858. if intersect_GM == 1
  859. VOIimg = (VOIimg > 0.5).*(GMimg > GM_CUTOFF);
  860. elseif intersect_WM == 1
  861. VOIimg = (VOIimg > 0.5).*(WMimg > WM_CUTOFF);
  862. end
  863. final_VOI_mask = (VOIimg > 0.5).*brain_mask > 0;
  864. results_number_voxels_VOI(subj,1+voi) = {nnz(final_VOI_mask(:) > 0)};
  865. if nnz(final_VOI_mask(:) > 0) < min_number_voxels
  866. continue;
  867. end
  868. C_MEASURED = zeros(nr_frames,1);
  869. for frame = 1:nr_frames
  870. clear tmp values
  871. tmp = dydata(:,:,:,frame);
  872. values = tmp(final_VOI_mask > 0);
  873. C_MEASURED(frame) = mean(values(~isnan(values)));
  874. end
  875. if window_size > 0
  876. % temporal filtering using a median filter
  877. C_MEASURED = medfilt1(C_MEASURED, window_size);
  878. end
  879. if sum(abs(C_MEASURED)) == 0
  880. continue;
  881. end
  882. if sum(isnan(C_MEASURED)) > 0
  883. continue;
  884. end
  885. % CALCULATE ALL THE MODELS
  886. if figures_on == 1 || save_figures == 1
  887. close(3);
  888. hfig3 = figure(3);
  889. set(hfig3,'Name',[subjectname ' - ' VOIname]);
  890. close(4);
  891. hfig4 = figure(4);
  892. set(hfig4,'Name',[subjectname ' - ' VOIname]);
  893. end
  894. for m = 1:nr_models
  895. modelname = model_list{m,1};
  896. if strcmp(modelname,'Logan_input')
  897. clear VD error
  898. if figures_on == 1 || save_figures == 1
  899. figure(3);
  900. [DV,error] = LCN_LOGAN(MIDSCANTIMES(frames_ok),C_MEASURED(frames_ok),time_input,corrected_input,logan_start_time,3);
  901. title('Logan input');
  902. if save_figures == 1
  903. cd(dir_figures);
  904. saveas(hfig3,['fig_Logan_input_VOI_' VOIname '_' suffix '.fig']);
  905. else
  906. pause
  907. end
  908. else
  909. [DV,error] = LCN_LOGAN(MIDSCANTIMES(frames_ok),C_MEASURED(frames_ok),time_input,corrected_input,logan_start_time,0);
  910. end
  911. results_region_based_Logan_input_DV(subj,1+voi) = {DV};
  912. results_region_based_Logan_input_error(subj,1+voi) = {error};
  913. if save_parcelimgs
  914. atlas_Logan_input_DV(atlas_orig == parcel_values(voi)) = DV;
  915. atlas_Logan_input_error(atlas_orig == parcel_values(voi)) = error;
  916. Logan_outputname1 = fullfile(dir_firstlevel,['w' subjectname '_' suffix '_atlas_Logan_input_DV.nii']);
  917. Logan_outputname2 = fullfile(dir_firstlevel,['w' subjectname '_' suffix '_atlas_Logan_input_error.nii']);
  918. LCN12_write_image(atlas_Logan_input_DV,Logan_outputname1, '_' + suffix + '_Logan input DV',64,Vatlas_orig);
  919. LCN12_write_image(atlas_Logan_input_error,Logan_outputname2, '_' + suffix + '_Logan input error',64,Vatlas_orig);
  920. end
  921. end
  922. if strcmp(modelname,'2T4k')
  923. clear tmpA tmpB index_min kfit_2T4k cost_function axvalues k0
  924. % start new fit from different starting positions
  925. tmpA = zeros(nr_k0_2T4k,4);
  926. tmpB = zeros(nr_k0_2T4k,1);
  927. cost_function = @(params) norm(WEIGHTS_PET.*(LCN_calc2_model_2T4k(params,MIDSCANTIMES,FRAMEDURATION,CA_FINETIMES,FINETIMES,CALC_OPTION,STEP) - C_MEASURED));
  928. parfor j = 1:nr_k0_2T4k
  929. k0 = k0_2T4k_all_values(j,:);
  930. [tmpA(j,:),tmpB(j)] = fmincon(cost_function,k0,[],[],[],[],k0_2T4k_lower_bound,k0_2T4k_upper_bound,[],options);
  931. end
  932. index_min = find(tmpB == min(tmpB));
  933. kfit_2T4k = tmpA(index_min(1),:);
  934. results_region_based_2T4k_K1(subj,1+voi) = {kfit_2T4k(1)};
  935. results_region_based_2T4k_k2(subj,1+voi) = {kfit_2T4k(2)};
  936. results_region_based_2T4k_k3(subj,1+voi) = {kfit_2T4k(3)};
  937. results_region_based_2T4k_k4(subj,1+voi) = {kfit_2T4k(4)};
  938. results_region_based_2T4k_DV(subj,1+voi) = {kfit_2T4k(1)*(1+kfit_2T4k(3)/kfit_2T4k(4))/kfit_2T4k(2)};
  939. results_region_based_2T4k_error(subj,1+voi) = {tmpB(index_min(1))./mean(C_MEASURED)}; % relative error
  940. if save_parcelimgs
  941. atlas_2T4k_K1(atlas_orig == parcel_values(voi)) = kfit_2T4k(1);
  942. atlas_2T4k_k2(atlas_orig == parcel_values(voi)) = kfit_2T4k(2);
  943. atlas_2T4k_k3(atlas_orig == parcel_values(voi)) = kfit_2T4k(3);
  944. atlas_2T4k_k4(atlas_orig == parcel_values(voi)) = kfit_2T4k(4);
  945. atlas_2T4k_DV(atlas_orig == parcel_values(voi)) = kfit_2T4k(1)*(1+kfit_2T4k(3)/kfit_2T4k(4))/kfit_2T4k(2);
  946. atlas_2T4k_error(atlas_orig == parcel_values(voi)) = tmpB(index_min(1))./mean(C_MEASURED);
  947. twoT4k_outputname1 = fullfile(dir_firstlevel,['w' subjectname '_' suffix '_atlas_2T4k_K1.nii']);
  948. twoT4k_outputname2 = fullfile(dir_firstlevel,['w' subjectname '_' suffix '_atlas_2T4k_k2.nii']);
  949. twoT4k_outputname3 = fullfile(dir_firstlevel,['w' subjectname '_' suffix '_atlas_2T4k_k3.nii']);
  950. twoT4k_outputname4 = fullfile(dir_firstlevel,['w' subjectname '_' suffix '_atlas_2T4k_k4.nii']);
  951. twoT4k_outputname6 = fullfile(dir_firstlevel,['w' subjectname '_' suffix '_atlas_2T4k_DV.nii']);
  952. twoT4k_outputname7 = fullfile(dir_firstlevel,['w' subjectname '_' suffix '_atlas_2T4k_error.nii']);
  953. LCN12_write_image(atlas_2T4k_K1,twoT4k_outputname1,'_' + suffix + '_2T4k_K1',64,Vatlas_orig);
  954. LCN12_write_image(atlas_2T4k_k2,twoT4k_outputname2,'_' + suffix + '_2T4k_k2',64,Vatlas_orig);
  955. LCN12_write_image(atlas_2T4k_k3,twoT4k_outputname3,'_' + suffix + '_2T4k_k3',64,Vatlas_orig);
  956. LCN12_write_image(atlas_2T4k_k4,twoT4k_outputname4,'_' + suffix + '_2T4k_k4',64,Vatlas_orig);
  957. LCN12_write_image(atlas_2T4k_DV,twoT4k_outputname6,'_' + suffix + '_2T4k_DV',64,Vatlas_orig);
  958. LCN12_write_image(atlas_2T4k_error,twoT4k_outputname7,'_' + suffix + '_2T4k_error',64,Vatlas_orig);
  959. end
  960. [AIC,SC] = LCN_calc_model_selection(nnz(WEIGHTS_PET),tmpB(index_min(1)).^2,nr_params_2T4k);
  961. results_region_based_AIC((subj-1)*4+1,2) = {modelname};
  962. results_region_based_SC((subj-1)*4+1,2) = {modelname};
  963. results_region_based_AIC((subj-1)*4+1,2+voi) = {AIC};
  964. results_region_based_SC((subj-1)*4+1,2+voi) = {SC};
  965. if figures_on == 1 || save_figures == 1
  966. figure(4)
  967. subplot(221)
  968. plot(MIDSCANTIMES,C_MEASURED,'ob:');
  969. hold on
  970. plot(MIDSCANTIMES(excluded_frames),C_MEASURED(excluded_frames),'*r'); % indicating unreliable data due to head movements
  971. xlabel('time in min');
  972. ylabel('kBq/ml');
  973. title('2T4k');
  974. plot(MIDSCANTIMES,LCN_calc2_model_2T4k(kfit_2T4k,MIDSCANTIMES,FRAMEDURATION,CA_FINETIMES,FINETIMES,CALC_OPTION,STEP),'k')
  975. axvalues = axis;
  976. text(axvalues(2)*0.5,axvalues(3)+0.1*(axvalues(4)-axvalues(3)),['VD = ' num2str(kfit_2T4k(1)*(1+kfit_2T4k(3)/kfit_2T4k(4))/kfit_2T4k(2))]);
  977. end
  978. end
  979. if strcmp(modelname,'2T4k_Vb')
  980. clear tmpA tmpB index_min kfit_2T4k_Vb cost_function axvalues k0
  981. % start new fit from different starting positions
  982. tmpA = zeros(nr_k0_2T4k_Vb,5);
  983. tmpB = zeros(nr_k0_2T4k_Vb,1);
  984. cost_function = @(params) norm(WEIGHTS_PET.*(LCN_calc2_model_2T4k_Vb(params,MIDSCANTIMES,FRAMEDURATION,CA_FINETIMES,CA_WB_FINETIMES,FINETIMES,CALC_OPTION,STEP) - C_MEASURED));
  985. parfor j = 1:nr_k0_2T4k_Vb
  986. k0 = k0_2T4k_Vb_all_values(j,:);
  987. [tmpA(j,:),tmpB(j)] = fmincon(cost_function,k0,[],[],[],[],k0_2T4k_Vb_lower_bound,k0_2T4k_Vb_upper_bound,[],options);
  988. end
  989. index_min = find(tmpB == min(tmpB));
  990. kfit_2T4k_Vb = tmpA(index_min(1),:);
  991. results_region_based_2T4k_Vb_K1(subj,1+voi) = {kfit_2T4k_Vb(1)};
  992. results_region_based_2T4k_Vb_k2(subj,1+voi) = {kfit_2T4k_Vb(2)};
  993. results_region_based_2T4k_Vb_k3(subj,1+voi) = {kfit_2T4k_Vb(3)};
  994. results_region_based_2T4k_Vb_k4(subj,1+voi) = {kfit_2T4k_Vb(4)};
  995. results_region_based_2T4k_Vb_Vb(subj,1+voi) = {kfit_2T4k_Vb(5)};
  996. results_region_based_2T4k_Vb_DV(subj,1+voi) = {kfit_2T4k_Vb(1)*(1+kfit_2T4k_Vb(3)/kfit_2T4k_Vb(4))/kfit_2T4k_Vb(2)};
  997. results_region_based_2T4k_Vb_error(subj,1+voi) = {tmpB(index_min(1))./mean(C_MEASURED)}; % relative error
  998. if save_parcelimgs
  999. atlas_2T4k_Vb_K1(atlas_orig == parcel_values(voi)) = kfit_2T4k_Vb(1);
  1000. atlas_2T4k_Vb_k2(atlas_orig == parcel_values(voi)) = kfit_2T4k_Vb(2);
  1001. atlas_2T4k_Vb_k3(atlas_orig == parcel_values(voi)) = kfit_2T4k_Vb(3);
  1002. atlas_2T4k_Vb_k4(atlas_orig == parcel_values(voi)) = kfit_2T4k_Vb(4);
  1003. atlas_2T4k_Vb_Vb(atlas_orig == parcel_values(voi)) = kfit_2T4k_Vb(5);
  1004. atlas_2T4k_Vb_DV(atlas_orig == parcel_values(voi)) = kfit_2T4k_Vb(1)*(1+kfit_2T4k_Vb(3)/kfit_2T4k_Vb(4))/kfit_2T4k_Vb(2);
  1005. atlas_2T4k_Vb_error(atlas_orig == parcel_values(voi)) = tmpB(index_min(1))./mean(C_MEASURED);
  1006. twoT4k_Vb_outputname1 = fullfile(dir_firstlevel,['w' subjectname '_' suffix '_atlas_2T4k_Vb_K1.nii']);
  1007. twoT4k_Vb_outputname2 = fullfile(dir_firstlevel,['w' subjectname '_' suffix '_atlas_2T4k_Vb_k2.nii']);
  1008. twoT4k_Vb_outputname3 = fullfile(dir_firstlevel,['w' subjectname '_' suffix '_atlas_2T4k_Vb_k3.nii']);
  1009. twoT4k_Vb_outputname4 = fullfile(dir_firstlevel,['w' subjectname '_' suffix '_atlas_2T4k_Vb_k4.nii']);
  1010. twoT4k_Vb_outputname5 = fullfile(dir_firstlevel,['w' subjectname '_' suffix '_atlas_2T4k_Vb_Vb.nii']);
  1011. twoT4k_Vb_outputname6 = fullfile(dir_firstlevel,['w' subjectname '_' suffix '_atlas_2T4k_Vb_DV.nii']);
  1012. twoT4k_Vb_outputname7 = fullfile(dir_firstlevel,['w' subjectname '_' suffix '_atlas_2T4k_Vb_error.nii']);
  1013. LCN12_write_image(atlas_2T4k_Vb_K1,twoT4k_Vb_outputname1,'_' + suffix + '2T4k_Vb_K1',64,Vatlas_orig);
  1014. LCN12_write_image(atlas_2T4k_Vb_k2,twoT4k_Vb_outputname2,'_' + suffix + '2T4k_Vb_k2',64,Vatlas_orig);
  1015. LCN12_write_image(atlas_2T4k_Vb_k3,twoT4k_Vb_outputname3,'_' + suffix + '2T4k_Vb_k3',64,Vatlas_orig);
  1016. LCN12_write_image(atlas_2T4k_Vb_k4,twoT4k_Vb_outputname4,'_' + suffix + '2T4k_Vb_k4',64,Vatlas_orig);
  1017. LCN12_write_image(atlas_2T4k_Vb_Vb,twoT4k_Vb_outputname5,'_' + suffix + '2T4k_Vb_Vb',64,Vatlas_orig);
  1018. LCN12_write_image(atlas_2T4k_Vb_DV,twoT4k_Vb_outputname6,'_' + suffix + '2T4k_Vb_DV',64,Vatlas_orig);
  1019. LCN12_write_image(atlas_2T4k_Vb_error,twoT4k_Vb_outputname7,'_' + suffix + '2T4k_Vb_error',64,Vatlas_orig);
  1020. end
  1021. [AIC,SC] = LCN_calc_model_selection(nnz(WEIGHTS_PET),tmpB(index_min(1)).^2,nr_params_2T4k_Vb);
  1022. results_region_based_AIC((subj-1)*4+2,2) = {modelname};
  1023. results_region_based_SC((subj-1)*4+2,2) = {modelname};
  1024. results_region_based_AIC((subj-1)*4+2,2+voi) = {AIC};
  1025. results_region_based_SC((subj-1)*4+2,2+voi) = {SC};
  1026. if figures_on == 1 || save_figures == 1
  1027. figure(4)
  1028. subplot(222)
  1029. plot(MIDSCANTIMES,C_MEASURED,'ob:');
  1030. hold on
  1031. plot(MIDSCANTIMES(excluded_frames),C_MEASURED(excluded_frames),'*r'); % indicating unreliable data due to head movements
  1032. xlabel('time in min');
  1033. ylabel('kBq/ml');
  1034. title('2T4k\_Vb');
  1035. plot(MIDSCANTIMES,LCN_calc2_model_2T4k_Vb(kfit_2T4k_Vb,MIDSCANTIMES,FRAMEDURATION,CA_FINETIMES,CA_WB_FINETIMES,FINETIMES,CALC_OPTION,STEP),'k')
  1036. axvalues = axis;
  1037. text(axvalues(2)*0.5,axvalues(3)+0.1*(axvalues(4)-axvalues(3)),['VD = ' num2str(kfit_2T4k_Vb(1)*(1+kfit_2T4k_Vb(3)/kfit_2T4k_Vb(4))/kfit_2T4k_Vb(2))]);
  1038. end
  1039. end
  1040. if strcmp(modelname,'2T4k_vasc1k')
  1041. clear tmpA tmpB index_min kfit_2T4k_vasc1k cost_function axvalues k0
  1042. % start new fit from different starting positions
  1043. tmpA = zeros(nr_k0_2T4k_vasc1k,6);
  1044. tmpB = zeros(nr_k0_2T4k_vasc1k,1);
  1045. cost_function = @(params) norm(WEIGHTS_PET.*(LCN_calc_model_2T4k_vasc1k(params,MIDSCANTIMES,FRAMEDURATION,CA_FINETIMES,CA_WB_FINETIMES,FINETIMES,CALC_OPTION,STEP) - C_MEASURED));
  1046. parfor j = 1:nr_k0_2T4k_vasc1k
  1047. k0 = k0_2T4k_vasc1k_all_values(j,:);
  1048. [tmpA(j,:),tmpB(j)] = fmincon(cost_function,k0,[],[],[],[],k0_2T4k_vasc1k_lower_bound,k0_2T4k_vasc1k_upper_bound,[],options);
  1049. end
  1050. index_min = find(tmpB == min(tmpB));
  1051. kfit_2T4k_vasc1k = tmpA(index_min(1),:);
  1052. results_region_based_2T4k_vasc1k_K1(subj,1+voi) = {kfit_2T4k_vasc1k(1)};
  1053. results_region_based_2T4k_vasc1k_k2(subj,1+voi) = {kfit_2T4k_vasc1k(2)};
  1054. results_region_based_2T4k_vasc1k_k3(subj,1+voi) = {kfit_2T4k_vasc1k(3)};
  1055. results_region_based_2T4k_vasc1k_k4(subj,1+voi) = {kfit_2T4k_vasc1k(4)};
  1056. results_region_based_2T4k_vasc1k_Vb(subj,1+voi) = {kfit_2T4k_vasc1k(5)};
  1057. results_region_based_2T4k_vasc1k_K1v(subj,1+voi) = {kfit_2T4k_vasc1k(6)};
  1058. results_region_based_2T4k_vasc1k_DV(subj,1+voi) = {kfit_2T4k_vasc1k(1)*(1+kfit_2T4k_vasc1k(3)/kfit_2T4k_vasc1k(4))/kfit_2T4k_vasc1k(2)};
  1059. results_region_based_2T4k_vasc1k_error(subj,1+voi) = {tmpB(index_min(1))./mean(C_MEASURED)}; % relative error
  1060. if save_parcelimgs
  1061. atlas_2T4k_vasc1k_K1(atlas_orig == parcel_values(voi)) = kfit_2T4k_vasc1k(1);
  1062. atlas_2T4k_vasc1k_k2(atlas_orig == parcel_values(voi)) = kfit_2T4k_vasc1k(2);
  1063. atlas_2T4k_vasc1k_k3(atlas_orig == parcel_values(voi)) = kfit_2T4k_vasc1k(3);
  1064. atlas_2T4k_vasc1k_k4(atlas_orig == parcel_values(voi)) = kfit_2T4k_vasc1k(4);
  1065. atlas_2T4k_vasc1k_Vb(atlas_orig == parcel_values(voi)) = kfit_2T4k_vasc1k(5);
  1066. atlas_2T4k_vasc1k_K1v(atlas_orig == parcel_values(voi)) = kfit_2T4k_vasc1k(6);
  1067. atlas_2T4k_vasc1k_DV(atlas_orig == parcel_values(voi)) = kfit_2T4k_vasc1k(1)*(1+kfit_2T4k_vasc1k(3)/kfit_2T4k_vasc1k(4))/kfit_2T4k_vasc1k(2);
  1068. atlas_2T4k_vasc1k_error(atlas_orig == parcel_values(voi)) = tmpB(index_min(1))./mean(C_MEASURED);
  1069. twoT4k_vasc1k_outputname1 = fullfile(dir_firstlevel,['w' subjectname '_' suffix '_atlas_2T4k_vasc1k_K1.nii']);
  1070. twoT4k_vasc1k_outputname2 = fullfile(dir_firstlevel,['w' subjectname '_' suffix '_atlas_2T4k_vasc1k_k2.nii']);
  1071. twoT4k_vasc1k_outputname3 = fullfile(dir_firstlevel,['w' subjectname '_' suffix '_atlas_2T4k_vasc1k_k3.nii']);
  1072. twoT4k_vasc1k_outputname4 = fullfile(dir_firstlevel,['w' subjectname '_' suffix '_atlas_2T4k_vasc1k_k4.nii']);
  1073. twoT4k_vasc1k_outputname5 = fullfile(dir_firstlevel,['w' subjectname '_' suffix '_atlas_2T4k_vasc1k_Vb.nii']);
  1074. twoT4k_vasc1k_outputname6 = fullfile(dir_firstlevel,['w' subjectname '_' suffix '_atlas_2T4k_vasc1k_K1v.nii']);
  1075. twoT4k_vasc1k_outputname7 = fullfile(dir_firstlevel,['w' subjectname '_' suffix '_atlas_2T4k_vasc1k_DV.nii']);
  1076. twoT4k_vasc1k_outputname8 = fullfile(dir_firstlevel,['w' subjectname '_' suffix '_atlas_2T4k_vasc1k_error.nii']);
  1077. LCN12_write_image(atlas_2T4k_vasc1k_K1,twoT4k_vasc1k_outputname1,'_' + suffix + '2T4k_vasc1k_K1',64,Vatlas_orig);
  1078. LCN12_write_image(atlas_2T4k_vasc1k_k2,twoT4k_vasc1k_outputname2,'_' + suffix + '2T4k_vasc1k_k2',64,Vatlas_orig);
  1079. LCN12_write_image(atlas_2T4k_vasc1k_k3,twoT4k_vasc1k_outputname3,'_' + suffix + '2T4k_vasc1k_k3',64,Vatlas_orig);
  1080. LCN12_write_image(atlas_2T4k_vasc1k_k4,twoT4k_vasc1k_outputname4,'_' + suffix + '2T4k_vasc1k_k4',64,Vatlas_orig);
  1081. LCN12_write_image(atlas_2T4k_vasc1k_Vb,twoT4k_vasc1k_outputname5,'_' + suffix + '2T4k_vasc1k_Vb',64,Vatlas_orig);
  1082. LCN12_write_image(atlas_2T4k_vasc1k_K1v,twoT4k_vasc1k_outputname6,'_' + suffix + '2T4k_vasc1k_K1v',64,Vatlas_orig);
  1083. LCN12_write_image(atlas_2T4k_vasc1k_DV,twoT4k_vasc1k_outputname7,'_' + suffix + '2T4k_vasc1k_DV',64,Vatlas_orig);
  1084. LCN12_write_image(atlas_2T4k_vasc1k_error,twoT4k_vasc1k_outputname8,'_' + suffix + '2T4k_vasc1k_error',64,Vatlas_orig);
  1085. end
  1086. [AIC,SC] = LCN_calc_model_selection(nnz(WEIGHTS_PET),tmpB(index_min(1)).^2,nr_params_2T4k_Vb);
  1087. results_region_based_AIC((subj-1)*4+3,2) = {modelname};
  1088. results_region_based_SC((subj-1)*4+3,2) = {modelname};
  1089. results_region_based_AIC((subj-1)*4+3,2+voi) = {AIC};
  1090. results_region_based_SC((subj-1)*4+3,2+voi) = {SC};
  1091. if figures_on == 1 || save_figures == 1
  1092. figure(4)
  1093. subplot(223)
  1094. plot(MIDSCANTIMES,C_MEASURED,'ob:');
  1095. hold on
  1096. plot(MIDSCANTIMES(excluded_frames),C_MEASURED(excluded_frames),'*r'); % indicating unreliable data due to head movements
  1097. xlabel('time in min');
  1098. ylabel('kBq/ml');
  1099. title('2T4K\_vasc1k');
  1100. plot(MIDSCANTIMES,LCN_calc_model_2T4k_vasc1k(kfit_2T4k_vasc1k,MIDSCANTIMES,FRAMEDURATION,CA_FINETIMES,CA_WB_FINETIMES,FINETIMES,CALC_OPTION,STEP),'k')
  1101. axvalues = axis;
  1102. text(axvalues(2)*0.5,axvalues(3)+0.1*(axvalues(4)-axvalues(3)),['VD = ' num2str(kfit_2T4k_vasc1k(1)*(1+kfit_2T4k_vasc1k(3)/kfit_2T4k_vasc1k(4))/kfit_2T4k_vasc1k(2))]);
  1103. end
  1104. end
  1105. if strcmp(modelname,'2T4k_vasc2k')
  1106. clear tmpA tmpB index_min kfit_2T4k_vasc2k cost_function axvalues k0
  1107. % start new fit from different starting positions
  1108. tmpA = zeros(nr_k0_2T4k_vasc2k,7);
  1109. tmpB = zeros(nr_k0_2T4k_vasc2k,1);
  1110. cost_function = @(params) norm(WEIGHTS_PET.*(LCN_calc_model_2T4k_vasc2k(params,MIDSCANTIMES,FRAMEDURATION,CA_FINETIMES,CA_WB_FINETIMES,FINETIMES,CALC_OPTION,STEP) - C_MEASURED));
  1111. parfor j = 1:nr_k0_2T4k_vasc2k
  1112. k0 = k0_2T4k_vasc2k_all_values(j,:);
  1113. [tmpA(j,:),tmpB(j)] = fmincon(cost_function,k0,[],[],[],[],k0_2T4k_vasc2k_lower_bound,k0_2T4k_vasc2k_upper_bound,[],options);
  1114. end
  1115. index_min = find(tmpB == min(tmpB));
  1116. kfit_2T4k_vasc2k = tmpA(index_min(1),:);
  1117. results_region_based_2T4k_vasc2k_K1(subj,1+voi) = {kfit_2T4k_vasc2k(1)};
  1118. results_region_based_2T4k_vasc2k_k2(subj,1+voi) = {kfit_2T4k_vasc2k(2)};
  1119. results_region_based_2T4k_vasc2k_k3(subj,1+voi) = {kfit_2T4k_vasc2k(3)};
  1120. results_region_based_2T4k_vasc2k_k4(subj,1+voi) = {kfit_2T4k_vasc2k(4)};
  1121. results_region_based_2T4k_vasc2k_Vb(subj,1+voi) = {kfit_2T4k_vasc2k(5)};
  1122. results_region_based_2T4k_vasc2k_K1v(subj,1+voi) = {kfit_2T4k_vasc2k(6)};
  1123. results_region_based_2T4k_vasc2k_k2v(subj,1+voi) = {kfit_2T4k_vasc2k(7)};
  1124. results_region_based_2T4k_vasc2k_DV(subj,1+voi) = {kfit_2T4k_vasc2k(1)*(1+kfit_2T4k_vasc2k(3)/kfit_2T4k_vasc2k(4))/kfit_2T4k_vasc2k(2)};
  1125. results_region_based_2T4k_vasc2k_error(subj,1+voi) = {tmpB(index_min(1))./mean(C_MEASURED)}; % relative error
  1126. if save_parcelimgs
  1127. atlas_2T4k_vasc2k_K1(atlas_orig == parcel_values(voi)) = kfit_2T4k_vasc2k(1);
  1128. atlas_2T4k_vasc2k_k2(atlas_orig == parcel_values(voi)) = kfit_2T4k_vasc2k(2);
  1129. atlas_2T4k_vasc2k_k3(atlas_orig == parcel_values(voi)) = kfit_2T4k_vasc2k(3);
  1130. atlas_2T4k_vasc2k_k4(atlas_orig == parcel_values(voi)) = kfit_2T4k_vasc2k(4);
  1131. atlas_2T4k_vasc2k_Vb(atlas_orig == parcel_values(voi)) = kfit_2T4k_vasc2k(5);
  1132. atlas_2T4k_vasc2k_K1v(atlas_orig == parcel_values(voi)) = kfit_2T4k_vasc2k(6);
  1133. atlas_2T4k_vasc2k_k2v(atlas_orig == parcel_values(voi)) = kfit_2T4k_vasc2k(7);
  1134. atlas_2T4k_vasc2k_DV(atlas_orig == parcel_values(voi)) = kfit_2T4k_vasc2k(1)*(1+kfit_2T4k_vasc2k(3)/kfit_2T4k_vasc2k(4))/kfit_2T4k_vasc2k(2);
  1135. atlas_2T4k_vasc2k_error(atlas_orig == parcel_values(voi)) = tmpB(index_min(1))./mean(C_MEASURED);
  1136. twoT4k_vasc2k_outputname1 = fullfile(dir_firstlevel,['w' subjectname '_' suffix '_atlas_2T4k_vasc2k_K1.nii']);
  1137. twoT4k_vasc2k_outputname2 = fullfile(dir_firstlevel,['w' subjectname '_' suffix '_atlas_2T4k_vasc2k_k2.nii']);
  1138. twoT4k_vasc2k_outputname3 = fullfile(dir_firstlevel,['w' subjectname '_' suffix '_atlas_2T4k_vasc2k_k3.nii']);
  1139. twoT4k_vasc2k_outputname4 = fullfile(dir_firstlevel,['w' subjectname '_' suffix '_atlas_2T4k_vasc2k_k4.nii']);
  1140. twoT4k_vasc2k_outputname5 = fullfile(dir_firstlevel,['w' subjectname '_' suffix '_atlas_2T4k_vasc2k_Vb.nii']);
  1141. twoT4k_vasc2k_outputname6 = fullfile(dir_firstlevel,['w' subjectname '_' suffix '_atlas_2T4k_vasc2k_K1v.nii']);
  1142. twoT4k_vasc2k_outputname7 = fullfile(dir_firstlevel,['w' subjectname '_' suffix '_atlas_2T4k_vasc2k_k2v.nii']);
  1143. twoT4k_vasc2k_outputname8 = fullfile(dir_firstlevel,['w' subjectname '_' suffix '_atlas_2T4k_vasc2k_DV.nii']);
  1144. twoT4k_vasc2k_outputname9 = fullfile(dir_firstlevel,['w' subjectname '_' suffix '_atlas_2T4k_vasc2k_error.nii']);
  1145. LCN12_write_image(atlas_2T4k_vasc2k_K1,twoT4k_vasc2k_outputname1,'_' + suffix + '2T4k_vasc2k_K1',64,Vatlas_orig);
  1146. LCN12_write_image(atlas_2T4k_vasc2k_k2,twoT4k_vasc2k_outputname2,'_' + suffix + '2T4k_vasc2k_k2',64,Vatlas_orig);
  1147. LCN12_write_image(atlas_2T4k_vasc2k_k3,twoT4k_vasc2k_outputname3,'_' + suffix + '2T4k_vasc2k_k3',64,Vatlas_orig);
  1148. LCN12_write_image(atlas_2T4k_vasc2k_k4,twoT4k_vasc2k_outputname4,'_' + suffix + '2T4k_vasc2k_k4',64,Vatlas_orig);
  1149. LCN12_write_image(atlas_2T4k_vasc2k_Vb,twoT4k_vasc2k_outputname5,'_' + suffix + '2T4k_vasc2k_Vb',64,Vatlas_orig);
  1150. LCN12_write_image(atlas_2T4k_vasc2k_K1v,twoT4k_vasc2k_outputname6,'_' + suffix + '2T4k_vasc2k_K1v',64,Vatlas_orig);
  1151. LCN12_write_image(atlas_2T4k_vasc2k_k2v,twoT4k_vasc2k_outputname7,'_' + suffix + '2T4k_vasc2k_k2v',64,Vatlas_orig);
  1152. LCN12_write_image(atlas_2T4k_vasc2k_DV,twoT4k_vasc2k_outputname8,'_' + suffix + '2T4k_vasc2k_DV',64,Vatlas_orig);
  1153. LCN12_write_image(atlas_2T4k_vasc2k_error,twoT4k_vasc2k_outputname9,'_' + suffix + '2T4k_vasc2k_error',64,Vatlas_orig);
  1154. end
  1155. [AIC,SC] = LCN_calc_model_selection(nnz(WEIGHTS_PET),tmpB(index_min(1)).^2,nr_params_2T4k_Vb);
  1156. results_region_based_AIC((subj-1)*4+4,2) = {modelname};
  1157. results_region_based_SC((subj-1)*4+4,2) = {modelname};
  1158. results_region_based_AIC((subj-1)*4+4,2+voi) = {AIC};
  1159. results_region_based_SC((subj-1)*4+4,2+voi) = {SC};
  1160. if figures_on == 1 || save_figures == 1
  1161. figure(4)
  1162. subplot(224)
  1163. plot(MIDSCANTIMES,C_MEASURED,'ob:');
  1164. hold on
  1165. plot(MIDSCANTIMES(excluded_frames),C_MEASURED(excluded_frames),'*r'); % indicating unreliable data due to head movements
  1166. xlabel('time in min');
  1167. ylabel('kBq/ml');
  1168. title('2T4K\_vasc2k');
  1169. plot(MIDSCANTIMES,LCN_calc_model_2T4k_vasc2k(kfit_2T4k_vasc2k,MIDSCANTIMES,FRAMEDURATION,CA_FINETIMES,CA_WB_FINETIMES,FINETIMES,CALC_OPTION,STEP),'k')
  1170. axvalues = axis;
  1171. text(axvalues(2)*0.5,axvalues(3)+0.1*(axvalues(4)-axvalues(3)),['VD = ' num2str(kfit_2T4k_vasc2k(1)*(1+kfit_2T4k_vasc2k(3)/kfit_2T4k_vasc2k(4))/kfit_2T4k_vasc2k(2))]);
  1172. end
  1173. end
  1174. end % for loop models
  1175. if save_figures == 1
  1176. cd(dir_figures);
  1177. saveas(hfig4,['fig_4models_' VOIname '_' suffix '.fig']);
  1178. else
  1179. pause
  1180. end
  1181. end % for loop VOIs
  1182. fprintf('atlas based analysis ended at %s \n',datetime('now'));
  1183. fprintf(fid,'atlas based analysis ended at %s \n',datetime('now'));
  1184. % GENERATE A VOXEL-BASED PARAMETRIC IMAGE FOR LOGAN INPUT
  1185. if do_voxelwise_logan
  1186. clear DV_Logan DV_Logan_error outputname1 outputname2 Vout1 Vout2
  1187. dimx = Vref.dim(1);
  1188. dimy = Vref.dim(2);
  1189. dimz = Vref.dim(3);
  1190. fprintf('start additional smoothing at %s \n',datetime('now'));
  1191. fprintf(fid,'start additional smoothing at %s \n',datetime('now'));
  1192. % smooth the images
  1193. sdydata = zeros(dimx*dimy*dimz,size(dydata,4));
  1194. if intersect_GM == 1
  1195. brain_mask = (brain_mask > 0).*(GMimg > GM_CUTOFF);
  1196. end
  1197. if intersect_WM == 1
  1198. brain_mask = (brain_mask > 0).*(WMimg > WM_CUTOFF);
  1199. end
  1200. for frame = 1:nr_frames
  1201. clear tmp stmp
  1202. tmp = squeeze(dydata(:,:,:,frame)).*(brain_mask > 0);
  1203. stmp = LCN12_smooth(tmp,[additional_smooth_parametric additional_smooth_parametric additional_smooth_parametric]./voxelsize_wPET,brain_mask);
  1204. sdydata(:,frame) = stmp(:);
  1205. end
  1206. fprintf('additional smoothing ended at %s \n',datetime('now'));
  1207. fprintf(fid,'additional smoothing ended at %s \n',datetime('now'));
  1208. % run voxel-based Logan analysis
  1209. indexlist = find(brain_mask(:) == 1);
  1210. datavalues = sdydata(indexlist,:);
  1211. tmpA = [];
  1212. tmpB = [];
  1213. tmp1 = zeros(dimx*dimy*dimz,1);
  1214. tmp2 = zeros(dimx*dimy*dimz,1);
  1215. fprintf('voxel based analysis for Logan_input started at %s \n',datetime('now'));
  1216. fprintf(fid,'voxel based analysis for Logan_input started at %s \n',datetime('now'));
  1217. datavalues_ok = datavalues(:,frames_ok);
  1218. midscantimes_ok = MIDSCANTIMES(frames_ok);
  1219. parfor i = 1:length(indexlist)
  1220. C_MEASURED = datavalues_ok(i,:)';
  1221. [DV,error] = LCN_LOGAN(midscantimes_ok,C_MEASURED,time_input,corrected_input,logan_start_time,0);
  1222. tmpA(i) = DV;
  1223. tmpB(i) = error;
  1224. end
  1225. tmp1(indexlist) = tmpA;
  1226. tmp2(indexlist) = tmpB;
  1227. DV_Logan = reshape(tmp1,dimx,dimy,dimz);
  1228. DV_Logan_error = reshape(tmp2,dimx,dimy,dimz);
  1229. % save images
  1230. outputname1 = fullfile(dir_firstlevel,['w' subjectname '_Logan_input_DV.nii']);
  1231. outputname2 = fullfile(dir_firstlevel,['w' subjectname '_Logan_input_error.nii']);
  1232. Vout1 = LCN12_write_image(DV_Logan,outputname1,'DV Logan',Vref.dt(1),Vref);
  1233. Vout2 = LCN12_write_image(DV_Logan_error,outputname2,'DV Logan error',Vref.dt(1),Vref);
  1234. fprintf('voxel based analysis for Logan_input ended at %s \n',datetime('now'));
  1235. fprintf(fid,'voxel based analysis for Logan_input ended at %s \n',datetime('now'));
  1236. end
  1237. end % for loop over subjects
  1238. %% SAVE THE RESULTS FOR THE REGION-BASED ANALYSIS
  1239. %--------------------------------------------------------------------------
  1240. for m = 1:nr_models
  1241. modelname = model_list{m,1};
  1242. if strcmp(modelname,'Logan_input')
  1243. outputfile_excel = [outputfile_excel_region_based '_' suffix '_Logan_input.xlsx'];
  1244. writetable(results_region_based_Logan_input_DV,outputfile_excel,'Sheet','DV');
  1245. writetable(results_region_based_Logan_input_error,outputfile_excel,'Sheet','error');
  1246. end
  1247. if strcmp(modelname,'2T4k')
  1248. outputfile_excel = [outputfile_excel_region_based '_' suffix '_2T4k.xlsx'];
  1249. writetable(results_region_based_2T4k_K1,outputfile_excel,'Sheet','K1');
  1250. writetable(results_region_based_2T4k_k2,outputfile_excel,'Sheet','k2');
  1251. writetable(results_region_based_2T4k_k3,outputfile_excel,'Sheet','k3');
  1252. writetable(results_region_based_2T4k_k4,outputfile_excel,'Sheet','k4');
  1253. writetable(results_region_based_2T4k_DV,outputfile_excel,'Sheet','DV');
  1254. writetable(results_region_based_2T4k_error,outputfile_excel,'Sheet','error');
  1255. end
  1256. if strcmp(modelname,'2T4k_Vb')
  1257. outputfile_excel = [outputfile_excel_region_based '_' suffix '_2T4k_Vb.xlsx'];
  1258. writetable(results_region_based_2T4k_Vb_K1,outputfile_excel,'Sheet','K1');
  1259. writetable(results_region_based_2T4k_Vb_k2,outputfile_excel,'Sheet','k2');
  1260. writetable(results_region_based_2T4k_Vb_k3,outputfile_excel,'Sheet','k3');
  1261. writetable(results_region_based_2T4k_Vb_k4,outputfile_excel,'Sheet','k4');
  1262. writetable(results_region_based_2T4k_Vb_Vb,outputfile_excel,'Sheet','Vb');
  1263. writetable(results_region_based_2T4k_Vb_DV,outputfile_excel,'Sheet','DV');
  1264. writetable(results_region_based_2T4k_Vb_error,outputfile_excel,'Sheet','error');
  1265. end
  1266. if strcmp(modelname,'2T4k_vasc1k')
  1267. outputfile_excel = [outputfile_excel_region_based '_' suffix '_2T4k_vasc1k.xlsx'];
  1268. writetable(results_region_based_2T4k_vasc1k_K1,outputfile_excel,'Sheet','K1');
  1269. writetable(results_region_based_2T4k_vasc1k_k2,outputfile_excel,'Sheet','k2');
  1270. writetable(results_region_based_2T4k_vasc1k_k3,outputfile_excel,'Sheet','k3');
  1271. writetable(results_region_based_2T4k_vasc1k_k4,outputfile_excel,'Sheet','k4');
  1272. writetable(results_region_based_2T4k_vasc1k_Vb,outputfile_excel,'Sheet','Vb');
  1273. writetable(results_region_based_2T4k_vasc1k_K1v,outputfile_excel,'Sheet','K1v');
  1274. writetable(results_region_based_2T4k_vasc1k_DV,outputfile_excel,'Sheet','DV');
  1275. writetable(results_region_based_2T4k_vasc1k_error,outputfile_excel,'Sheet','error');
  1276. end
  1277. if strcmp(modelname,'2T4k_vasc2k')
  1278. outputfile_excel = [outputfile_excel_region_based '_' suffix '_2T4k_vasc2k.xlsx'];
  1279. writetable(results_region_based_2T4k_vasc2k_K1,outputfile_excel,'Sheet','K1');
  1280. writetable(results_region_based_2T4k_vasc2k_k2,outputfile_excel,'Sheet','k2');
  1281. writetable(results_region_based_2T4k_vasc2k_k3,outputfile_excel,'Sheet','k3');
  1282. writetable(results_region_based_2T4k_vasc2k_k4,outputfile_excel,'Sheet','k4');
  1283. writetable(results_region_based_2T4k_vasc2k_Vb,outputfile_excel,'Sheet','Vb');
  1284. writetable(results_region_based_2T4k_vasc2k_K1v,outputfile_excel,'Sheet','K1v');
  1285. writetable(results_region_based_2T4k_vasc2k_k2v,outputfile_excel,'Sheet','k2v');
  1286. writetable(results_region_based_2T4k_vasc2k_DV,outputfile_excel,'Sheet','DV');
  1287. writetable(results_region_based_2T4k_vasc2k_error,outputfile_excel,'Sheet','error');
  1288. end
  1289. end
  1290. outputfile_excel = [outputfile_excel_region_based '_' suffix '_model_comparison_' char(datetime('today')) '.xlsx'];
  1291. writetable(results_region_based_AIC,outputfile_excel,'Sheet','AIC');
  1292. writetable(results_region_based_SC,outputfile_excel,'Sheet','SC');
  1293. outputfile_excel = [outputfile_excel_region_based '_' suffix '_nr_voxels_used_' char(datetime('today')) '.xlsx'];
  1294. writetable(results_number_voxels_VOI,outputfile_excel,'Sheet','nr of voxels');
  1295. cd(curdir);
  1296. fprintf('ALL DONE\n');

LaBGAScore_pet_model_TSPO_DPA714.m at commit 75a8bc9, under GPL-3.0 · at the source

Overview

Authors: Ynse Dooms1,2,3, Lixin Qiu1,3, Iris Coppieters1,3,4,5, Elfi Vergaelen6,7, Stephan Claes6,7, Patrick Dupont3,8, Melina Hehl2,3,9, Koen Cuypers2,3,10, Harald Engler11, Kirsten Dombrowski11, Kristin Verbeke12, Omer Van den Bergh13, Jeroen Raes14, Lukas Van Oudenhove1,3,15, Maaike Van Den Houte1,2,3, Katleen Bogaerts2,13
15 affiliations
  1. Laboratory for Brain-Gut Axis Studies (LaBGAS), Translational Research in Gastrointestinal Disorders (TARGID), Department of Chronic Diseases and Metabolism (CHROMETA), KU Leuven, Leuven, Belgium
  2. REVAL – Rehabilitation Research Center, Faculty of Rehabilitation Sciences, Hasselt University, Diepenbeek, Belgium
  3. Leuven Brain Institute, KU Leuven, Leuven, Belgium
  4. Pain in Motion Research Group (PAIN), Department of Physiotherapy, Faculty of Physical Education and Physiotherapy, Vrije Universiteit Brussel, Brussels, Belgium
  5. Experimental Health Psychology Research Group, Faculty of Psychology and Neuroscience, Maastricht University, Maastricht, 6211 LK, the Netherlands
  6. University Psychiatric Center KU Leuven, University Hospitals Leuven, Leuven, Belgium
  7. Mind Body Research, Psychiatry Research Group, Department of Neurosciences, KU Leuven, Leuven, Belgium
  8. Laboratory for Cognitive Neurology, Department of Neurosciences, KU Leuven, Leuven, Belgium
  9. Translational MRI, Department of Imaging & Pathology, KU Leuven, Leuven, Belgium
  10. Movement Control & Neuroplasticity Research Group, Department of Movement Sciences, Group Biomedical Sciences, KU Leuven, Heverlee, Belgium
  11. Institute of Medical Psychology and Behavioral Immunobiology, Center for Translational Neuro- and Behavioral Sciences (C-TNBS), University Hospital Essen, University of Duisburg-Essen, Essen, Germany
  12. Laboratory of Digestion and Absorption (DigALab), Translational Research Center in Gastrointestinal Disorders (TARGID), Department of Chronic Diseases and Metabolism (CHROMETA), KU Leuven, Leuven, Belgium
  13. Health Psychology, Faculty of Psychology and Educational Sciences, KU Leuven, Leuven, Belgium
  14. Laboratory of Molecular Bacteriology, Rega Institute, KU Leuven, Leuven, Belgium
  15. Cognitive & Affective Neuroscience Lab (CANLab), Department of Psychological and Brain Sciences, Dartmouth College, Hanover, NH, USA
Institutions: Hasselt University (Belgium); KU Leuven (Belgium); Vrije Universiteit Brussel (Belgium); Maastricht University (Netherlands); Pain in Motion (Belgium); Universitair Ziekenhuis Leuven (Belgium); Essen University Hospital (Germany); University of Duisburg-Essen (Germany); Dartmouth College (United States)
Journal: Brain, behavior, & immunity - health, volume 56, article 101299
Dates: received 27 February 2026; accepted 5 July 2026; published online 6 July 2026
Type: Research article · Language: English
License: CC BY-NC-ND
Identifiers: DOI 10.1016/j.bbih.2026.101299 · PMID 42472232 · PMCID PMC13380062 · OpenAlex W7167514348
Open access: gold, a free copy (OpenAlex)
Status: code verified
Categories: human (organism), clinical / translational (subfield)
Methods: Statistics, Smoothing, state filtering, decompositions, Machine learning, fMRI & imaging, Physiology & signal measures
Keywords: Fatigue, Inflammation, Neurophysiology, Gastrointestinal microbiome, Psychological stress
Topic: Fibromyalgia and Chronic Fatigue Syndrome Research (Psychiatry and Mental health, Medicine), according to OpenAlex
Funding: Research Foundation Flanders
Citations: not cited yet (Europe PMC); 170 references in the paper
Research resources: 2011 RRID:SCR_007037, 2012 RRID:SCR_009550, RRID:SCR_016216

Abstract

The abstract is not reproduced here: the paper's license (CC BY-NC-ND) does not allow it. Read it in the paper, at the publisher or on Europe PMC.

Repositories

Its files are read in the Code ↔ Paper reader above, with 16 matches between paragraphs and lines of code.

labgas/labgascore

License: GPL-3.0
State: the link answers, verified on 27 September 2026
Evidence: files inventoried
Commit: 75a8bc9e5bc708c2d5ca78efd2c05602220140b2, 24 September 2026
Languages: MATLAB (150), Python (5), Shell (3), SAS (2)
Size: 196 files, 160 scripts
Software Heritage: not archived
Found in: “Data availability”
Holds: README, license file
Not found: CITATION.cff, environment file, tests, continuous integration, documentation
Availability: 1 check, the latest on 27 September 2026: the link answers
  • 27 September 2026: the link answers
162 files

labgas/CANlab_help_examples

License: GPL-2.0
State: the link answers, verified on 27 September 2026
Evidence: files inventoried
Commit: 9c03690272e0e4cb534333588b19c337e5e4b228, 24 September 2026
Languages: MATLAB (222), Python (11), R (2)
Size: 393 files, 235 scripts
Software Heritage: not archived
Found in: “Data availability”
Holds: README, license file, documentation, 16 notebooks
Not found: CITATION.cff, environment file, tests, continuous integration
Tools: Statistics and Machine Learning Toolbox (43 files), Nipype (8 files), SPM (8 files), FSL (5 files), Parallel Computing Toolbox (5 files), NumPy (5 files), FreeSurfer (4 files), Image Processing Toolbox (4 files), pandas (4 files), cifti-matlab (2 files), GIfTI library for MATLAB (1 file), lme4 (1 file), lmerTest (1 file), Stan (1 file), statsmodels (1 file), Violinplot-Matlab (1 file)
Availability: 1 check, the latest on 27 September 2026: the link answers
  • 27 September 2026: the link answers
237 files

The paper's code and data availability statement is in the Data section.

Tracing map

Proposed by the machine: these links were found in the paper and verified at the source, without human review. The map will receive a Zenodo DOI once one of the paper's authors has validated it with their ORCID.

What the map holds:

  • 2 repositories of the authors' code, each at its verified commit, with its license and how the link was found in the paper;
  • 395 scripts, each with its path and the digest of its content;
  • 16 matches between paragraphs of the paper and lines of the code (method lexical-v1);
  • neither the text of the paper nor the code itself.

Its JSON (tracing-map.json) is deposited on Zenodo with its DOI once the map is validated.

Data

No dataset and no data link were found in the paper.

Code and data availability statement

The paper has a code and data availability statement. Its license (CC BY-NC-ND) does not allow reproducing it here; in short, from what the harvester recognized in it:

Read it in the paper: doi.org/10.1016/j.bbih.2026.101299.

Versions

The history of this record: each version stored by the harvester or made by a correction of its authors or of the maintainers of its code, and what changed in its facts. The texts of the paper (its abstract, its availability statements) are not part of it; versions that changed only those are not listed.

Version 1, 28 September 2026: the first record

Recorded: type, language, journal, volume, pages, dates, 16 authors, 5 keywords, 1 funder, 156 references, 3 RRIDs.

Cite

This paper

Dooms, Y., Qiu, L., Coppieters, I., Vergaelen, E., Claes, S., Dupont, P., Hehl, M., Cuypers, K., Engler, H., Dombrowski, K., Verbeke, K., Van den Bergh, O., Raes, J., Van Oudenhove, L., Van Den Houte, M., & Bogaerts, K. (2026). Multimodal approach to identify neuropsychophysiological subgroups in myalgic encephalomyelitis/chronic fatigue syndrome and their relevance for rehabilitation: protocol for a mechanistic cross-sectional and longitudinal study. Brain, behavior, & immunity - health, 56, 101299. https://doi.org/10.1016/j.bbih.2026.101299

BibTeX

@article{dooms2026multimodal,
author = {Dooms, Ynse and Qiu, Lixin and Coppieters, Iris and Vergaelen, Elfi and Claes, Stephan and Dupont, Patrick and Hehl, Melina and Cuypers, Koen and Engler, Harald and Dombrowski, Kirsten and Verbeke, Kristin and Van den Bergh, Omer and Raes, Jeroen and Van Oudenhove, Lukas and Van Den Houte, Maaike and Bogaerts, Katleen},
title = {{Multimodal approach to identify neuropsychophysiological subgroups in myalgic encephalomyelitis/chronic fatigue syndrome and their relevance for rehabilitation: protocol for a mechanistic cross-sectional and longitudinal study}},
journal = {Brain, behavior, \& immunity - health},
year = {2026},
month = jul,
volume = {56},
pages = {101299},
publisher = {Elsevier},
issn = {2666-3546},
doi = {10.1016/j.bbih.2026.101299},
url = {https://doi.org/10.1016/j.bbih.2026.101299},
pmid = {42472232},
pmcid = {PMC13380062}
}

RIS

TY - JOUR
AU - Dooms, Ynse
AU - Qiu, Lixin
AU - Coppieters, Iris
AU - Vergaelen, Elfi
AU - Claes, Stephan
AU - Dupont, Patrick
AU - Hehl, Melina
AU - Cuypers, Koen
AU - Engler, Harald
AU - Dombrowski, Kirsten
AU - Verbeke, Kristin
AU - Van den Bergh, Omer
AU - Raes, Jeroen
AU - Van Oudenhove, Lukas
AU - Van Den Houte, Maaike
AU - Bogaerts, Katleen
TI - Multimodal approach to identify neuropsychophysiological subgroups in myalgic encephalomyelitis/chronic fatigue syndrome and their relevance for rehabilitation: protocol for a mechanistic cross-sectional and longitudinal study
T2 - Brain, behavior, & immunity - health
J2 - Brain Behav Immun Health
PY - 2026
DA - 2026/07/06
VL - 56
SP - 101299
SN - 2666-3546
PB - Elsevier
DO - 10.1016/j.bbih.2026.101299
UR - https://doi.org/10.1016/j.bbih.2026.101299
LA - en
ER -

CSL-JSON

{
"id": "10.1016/j.bbih.2026.101299",
"type": "article-journal",
"title": "Multimodal approach to identify neuropsychophysiological subgroups in myalgic encephalomyelitis/chronic fatigue syndrome and their relevance for rehabilitation: protocol for a mechanistic cross-sectional and longitudinal study",
"container-title": "Brain, behavior, & immunity - health",
"author": [
{
"family": "Dooms",
"given": "Ynse"
},
{
"family": "Qiu",
"given": "Lixin"
},
{
"family": "Coppieters",
"given": "Iris"
},
{
"family": "Vergaelen",
"given": "Elfi"
},
{
"family": "Claes",
"given": "Stephan"
},
{
"family": "Dupont",
"given": "Patrick"
},
{
"family": "Hehl",
"given": "Melina"
},
{
"family": "Cuypers",
"given": "Koen"
},
{
"family": "Engler",
"given": "Harald"
},
{
"family": "Dombrowski",
"given": "Kirsten"
},
{
"family": "Verbeke",
"given": "Kristin"
},
{
"family": "Van den Bergh",
"given": "Omer"
},
{
"family": "Raes",
"given": "Jeroen"
},
{
"family": "Van Oudenhove",
"given": "Lukas"
},
{
"family": "Van Den Houte",
"given": "Maaike"
},
{
"family": "Bogaerts",
"given": "Katleen"
}
],
"container-title-short": "Brain Behav Immun Health",
"volume": "56",
"page": "101299",
"DOI": "10.1016/j.bbih.2026.101299",
"PMID": "42472232",
"PMCID": "PMC13380062",
"ISSN": "2666-3546",
"publisher": "Elsevier",
"URL": "https://doi.org/10.1016/j.bbih.2026.101299",
"language": "en",
"issued": {
"date-parts": [
[
2026,
7,
6
]
]
}
}

The tracing map gets a citation of its own once an author has validated it and it has a DOI.

Similar papers

The papers with a page that share the most with this one: the tools found in their code, their categories, datasets, cited references and authors, the rarest counting most.

[1] doi:10.1038/s41467-026-71151-2 [code]
Common and distinct neural correlates of social interaction processing and theory of mind in narratives.
Journal: Nature communications
In common: cifti-matlab, Nipype, Violinplot-Matlab, 12 other tools, 1 reference
[2] doi:10.1038/s41467-026-74565-0 [code]
The functional neurobiology of dispositions towards negative emotions.
Journal: Nature communications
In common: cifti-matlab, Violinplot-Matlab, GIfTI library for MATLAB, 11 other tools, 1 reference
[3] doi:10.1038/s41586-026-10631-3 [code]
A prognostic human brain network for diffuse midline glioma.
Journal: Nature
In common: cifti-matlab, GIfTI library for MATLAB, Tools for NIfTI and ANALYZE image (MATLAB), 10 other tools, clinical / translational
[4] doi:10.1002/hbm.70577 [code]
Disgust Propensity, Not Disgust Sensitivity, Shapes the Reactivity of a Subjective Disgust Circuit in Humans.
Journal: Human brain mapping
In common: cifti-matlab, Violinplot-Matlab, GIfTI library for MATLAB, 10 other tools
[5] doi:10.1038/s41467-026-71568-9 [code]
Convergent and selective representations of pain, appetitive processes, aversive processes, and cognitive control in the insula.
Journal: Nature communications
In common: Nipype, Parallel Computing Toolbox, FreeSurfer, 7 other tools, author Lukas Van Oudenhove
[6] doi:10.1002/hbm.70602 [code]
Neuroimaging Correlates of Post-Stroke Pain After Ischemic Stroke: Secondary Analysis of the INSPiRE-TMS Trial.
Journal: Human brain mapping
In common: cifti-matlab, GIfTI library for MATLAB, Tools for NIfTI and ANALYZE image (MATLAB), 9 other tools, clinical / translational
[7] doi:10.1111/ene.70678 [code]
Who Falls After a Stroke? Evidence From a Prospective Stroke Cohort.
Journal: European journal of neurology
In common: cifti-matlab, GIfTI library for MATLAB, Tools for NIfTI and ANALYZE image (MATLAB), 9 other tools, clinical / translational
[8] doi:10.1002/ana.78206 [code]
Multimodal Image Guidance in Subthalamic Deep Brain Stimulation for Parkinson's Disease.
Journal: Annals of neurology
In common: cifti-matlab, GIfTI library for MATLAB, Tools for NIfTI and ANALYZE image (MATLAB), 9 other tools, clinical / translational
[9] doi:10.1016/j.celrep.2026.117404 [code]
Action and rest tremor map to distinct networks within the primary motor cortex.
Journal: Cell reports
In common: cifti-matlab, GIfTI library for MATLAB, Tools for NIfTI and ANALYZE image (MATLAB), 9 other tools
[10] doi:10.1038/s42003-026-10276-y [code]
The cellular correlates and adolescent reorganisation of cortical myelination networks in the common marmoset.
Journal: Communications biology
In common: Nipype, GIfTI library for MATLAB, Optimization Toolbox, 9 other tools

Contribute

The authors of this paper can claim it, correct its record and validate its tracing map, and the maintainers of its code (its owner, or a public member of its organization) correct what it says of their repository; anyone signed in can ask for its removal. Every request goes to OSCR's own machine, which answers it; your account page follows them.

Sign in with ORCID to claim this paper as one of its authors, correct its record or validate its tracing map: when the paper's metadata lists your ORCID iD, you are recognized at once. Maintainers of its code: sign in with GitHub, then claim the repository on your account page.

Request its removal

To ask OSCR to remove this record, the copies of its authors' scripts or its tracing map, use the removal request page: signed in, you say who you are, what to remove and why, then review and confirm the request. Published rules decide every request (how).

Discussion, reproductions, activity

Discussion: questions and error reports about this paper and its code, from signed-in readers and its authors. It opens with sign-in.

Reproductions: reports from readers who ran the authors' code: what they reproduced, with which environment, commit and data. It opens with sign-in.

Activity: what happens around this paper: new versions of its record, its map's validation, discussions and reproductions. It opens with sign-in.