How to assign value to a variable depending on another array?
古いコメントを表示
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 件のコメント
Walter Roberson
2021 年 2 月 28 日
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
2021 年 2 月 28 日
Walter Roberson
2021 年 2 月 28 日
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
2021 年 2 月 28 日
Walter Roberson
2021 年 2 月 28 日
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
2021 年 2 月 28 日
Walter Roberson
2021 年 2 月 28 日
But distinguishing by folder name is effectively hard-coding, unless the folder name contains the TR as part of the name ?
Iugo
2021 年 2 月 28 日
Iugo
2021 年 3 月 1 日
Bob Thompson
2021 年 3 月 1 日
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
2021 年 3 月 1 日
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
2021 年 3 月 1 日
回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Matrix Indexing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
