How to assign value to a variable depending on another array?
Mostrar comentarios más antiguos
Hi everyone!
My code allows the user to choose between 16 folders, with each folder having this amount of files [15 23 24 33 36 36 37 39 41 44 48 59 61 75 113 169], noting that there are 2 folders with the same number of files. Since I'm dealing with fMRI time-series points, each folder will have a specific repetition time (TR), which will be [2.2 2.5 1.5 2 1.5 2 2 2.5 3 2 2 1.6 2 3 2 2].
I want to, after choosing the folder, calculate the sampling frequency (fs=1/TR) for that selected folder. How can I get the TR, based on the number of files for any eventually selected folder?
Thanks in advance!
12 comentarios
Walter Roberson
el 28 de Feb. de 2021
I cannot see any connection between the number of files and the TR values that you give.
For example the 5th and 6th both have 36 files but Tr is 1.5 and 2.
Going the other way, tr 1.5 corresponds to 24 and 36 files.
Iugo
el 28 de Feb. de 2021
Walter Roberson
el 28 de Feb. de 2021
if the number of files was 36 would the tr be 1.5 or would it be 2?
Are these dicom files? If so my memory from long ago is that the TR can be read from the Dicom headers.
Iugo
el 28 de Feb. de 2021
Walter Roberson
el 28 de Feb. de 2021
However, if you were to scamble the order of the folders, then you want to be able to get the correct TR just looking at the number of files in the current folder, correct? And if the number of files were 36, how would you know if you were dealing with TR 1.5 or 2 ?
Iugo
el 28 de Feb. de 2021
Walter Roberson
el 28 de Feb. de 2021
But distinguishing by folder name is effectively hard-coding, unless the folder name contains the TR as part of the name ?
Iugo
el 28 de Feb. de 2021
Iugo
el 1 de Mzo. de 2021
Bob Thompson
el 1 de Mzo. de 2021
You can always change the folder name within MATLAB, but doing so probably doesn't address the previous issue of knowing which folder needs which TR when they have the same number of files.
I suggest taking a step back and look at where the TR comes from. I assume you're producing the data with an external program, so is the TR captured there anywhere that it could be passed off with the rest of the captured data? Can be read out of the .mat file
Would it be possible to put the TR value in the folder name at this stage of the process? Can be read out of the name
Will the user who is post-processing the data be guaranteed to know the TR value? Can use an input to have them enter it
Walter Roberson
el 1 de Mzo. de 2021
If the data is available somehow, you could create a TR.mat inside each directory that had the appropriate TR for the directory stored inside it.
Iugo
el 1 de Mzo. de 2021
Respuestas (0)
Categorías
Más información sobre Matrix Indexing en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
