Scheduled service maintenance on November 22


On Friday, November 22, 2024, between 06:00 CET and 18:00 CET, GIN services will undergo planned maintenance. Extended service interruptions should be expected. We will try to keep downtimes to a minimum, but recommend that users avoid critical tasks, large data uploads, or DOI requests during this time.

We apologize for any inconvenience.

ery_4a_prep_s0_define_directories.m 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. %% ery_4a_prep_s0_define_directories
  2. %
  3. % This script defines the paths for the standard BIDS-compliant
  4. % directory structure for LaBGAS neuroimaging (datalad) datasets
  5. %
  6. % USAGE
  7. %
  8. % Script should be run from the root directory of the superdataset, e.g.
  9. % /data/proj_discoverie
  10. % It can be used standalone, but is typically called from the subsequent
  11. % scripts in the standard LaBGAScore workflow
  12. % The script is generic, i.e. it does not require study-specific adaptions
  13. %
  14. %
  15. % DEPENDENCIES
  16. %
  17. % spm12 on Matlab path WITHOUT subdirectories
  18. % no spm functions are called by this script,
  19. % but spmrootdir is defined automatically, for use in later scripts
  20. %
  21. %__________________________________________________________________________
  22. %
  23. % author: Lukas Van Oudenhove
  24. % date: November, 2021
  25. %
  26. %__________________________________________________________________________
  27. % @(#)% LaBGAScore_prep_s0_define_directories.m v1.1
  28. % last modified: 2022/03/16
  29. %% DEFINE DIRECTORIES AND ADD CODE DIR TO MATLAB PATH
  30. %--------------------------------------------------------------------------
  31. rootdir = pwd;
  32. githubrootdir = '/data/master_github_repos';
  33. sourcedir = fullfile(rootdir,'sourcedata');
  34. BIDSdir = fullfile(rootdir,'BIDS');
  35. codedir = fullfile(rootdir,'code');
  36. derivdir = fullfile(rootdir,'derivatives','fmriprep');
  37. matlabpath = path;
  38. if ~exist('spm.m','file')
  39. spmpathcommand = "addpath('your_spm_rootdir','-end')";
  40. error('\nspm12 not found on Matlab path, please add WITHOUT subfolders using the Matlab GUI or type %s in Matlab terminal before proceeding',spmpathcommand)
  41. else
  42. spmrootdir = which('spm.m');
  43. spmrootdir = strsplit(spmrootdir,'/spm.m');
  44. spmrootdir = spmrootdir{1,1};
  45. end
  46. if sum(contains(matlabpath,codedir)) == 0
  47. addpath(genpath(codedir),'-end');
  48. warning('\nadding %s to end of Matlab path',codedir)
  49. end
  50. %% READ IN SUBJECT LISTS AND COMPARE THEM
  51. %--------------------------------------------------------------------------
  52. sourcelist = dir(fullfile(sourcedir,'sub-*'));
  53. sourcesubjs = cellstr(char(sourcelist(:).name));
  54. BIDSlist = dir(fullfile(BIDSdir,'sub-*'));
  55. BIDSsubjs = cellstr(char(BIDSlist(:).name));
  56. derivlist = dir(fullfile(derivdir,'sub-*'));
  57. derivlist = derivlist([derivlist(:).isdir]);
  58. derivsubjs = cellstr(char(derivlist.name));
  59. if isequal(sourcesubjs,BIDSsubjs,derivsubjs)
  60. warning('\nnumbers and names of subjects in %s, %s, and %s match - good to go',sourcedir,BIDSdir,derivdir);
  61. else
  62. error('\nnumbers and names of subjects in %s, %s, and %s do not match - please check before proceeding and make sure your file organization is consistent with LaBGAS conventions',sourcedir,BIDSdir,derivdir);
  63. end
  64. %% CREATE CELL ARRAYS WITH FULL PATHS FOR SUBJECT DIRECTORIES
  65. %--------------------------------------------------------------------------
  66. for sourcesub = 1:size(sourcesubjs,1)
  67. sourcesubjdirs{sourcesub,1} = fullfile(sourcelist(sourcesub).folder,sourcelist(sourcesub).name);
  68. end
  69. for BIDSsub = 1:size(BIDSsubjs,1)
  70. BIDSsubjdirs{BIDSsub,1} = fullfile(BIDSlist(BIDSsub).folder,BIDSlist(BIDSsub).name);
  71. end
  72. for derivsub = 1:size(derivsubjs,1)
  73. derivsubjdirs{derivsub,1} = fullfile(derivlist(derivsub).folder,derivlist(derivsub).name);
  74. end
  75. %% CLEAN UP OBSOLETE VARIABLES
  76. %--------------------------------------------------------------------------
  77. clear sourcelist BIDSlist derivlist sourcesub BIDSsub derivsub