wildcard when setting directories

9 visualizaciones (últimos 30 días)
Kathleen Hupfeld
Kathleen Hupfeld el 22 de Feb. de 2018
Respondida: Arvind Narayanan el 2 de Mzo. de 2018
I want to set a directory path to use later in my code. However, each subject has a different folder name in their folder hierarchy: e.g., the full path to one person's folder hierarchy = 'C:\Users\APK-User\Documents\baseline\pp\3001\s001\2010\S001\con001.nii'
but the full path to another person's = 'C:\Users\APK-User\Documents\baseline\pp\3002\s002\2012\S002\con001.nii'
What could I do to have MatLab skip over the s002\2012\S002 portion of each person's path? Is there wildcard syntax I could use here? I couldn't get any combination I tried to work:
As an example, I want to be able to enter any subject in a subjID object array:
subjID={'3001'}
and then create their data path:
data_path = ['C:\Users\APK-User\Documents\baseline\pp\',subjID,'\','/s*','\','/2*','\','\S*'];
(& then I'm using SPM to select their .nii file:
a = spm_select('ExtFPList', fullfile(data_path),'^.*\.nii$');
The above syntax for data path doesn't work/doesn't skip over the file names properly. How could I get MatLab to do this?
  1 comentario
per isakson
per isakson el 22 de Feb. de 2018
Editada: per isakson el 22 de Feb. de 2018
subjID is a cell array, but need to be a character row.

Iniciar sesión para comentar.

Respuestas (1)

Arvind Narayanan
Arvind Narayanan el 2 de Mzo. de 2018
Hi Kathleen,
The variable subjID above is a cell array. If you would like to loop over its elements and use SPM to select the files, you can place your code inside a for loop with iterator i and refer to each element of subjID as
subjID{i}
If you would like to return a comma-separated list of the elements of subjID, use this notation
subjID{:}
Please refer to the documentation on working with cell arrays for more information: https://in.mathworks.com/help/releases/R2016b/matlab/matlab_prog/access-data-in-a-cell-array.html
Thanks,
Arvind

Categorías

Más información sobre Multidimensional Arrays en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by