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
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
Iugo 2021 年 2 月 28 日
Thanks for your reply!
I want to assign a value for the TR of the choosen folder automatically, without being hardcoded, and my first idea was getting that value based on the number of subjects of that folder.
I tried to do something like if the number of subjects of that folder is equal to one number in this vector [15 23 24 33 36 36 37 39 41 44 48 59 61 75 113 169], then the TR of that folder will correspond to the same index of the number in the vector equal to the number of subjects of that folder, but I got an error when I tried that...
Do you have any ideas?
Walter Roberson
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
Iugo 2021 年 2 月 28 日
If the number of files is 36 means that the folder X will have a TR of 1.5 and the folder Y will have a TR of 2.
I'm dealling with mat files, which are fMRI BOLD signals time-series and these TRs are used for further calculations.
Walter Roberson
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
Iugo 2021 年 2 月 28 日
That's my biggest issue, I dont know if I'm dealing with TR of 1.5 or 2 just based on number of files... the only way to distinguish between each other is by folder's name.
Walter Roberson
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
Iugo 2021 年 2 月 28 日
I don't have the TR as part of folder's name... you think if add that to the name will be possible to perform what I want to do?
Iugo
Iugo 2021 年 3 月 1 日
Dear @Walter Roberson, is it possible to add that information of TR for each folder, to the structure where are present all the information about that folder (as shown in the figure below)? For example, add a column to the right of the column datanum representing the TR values?
Thanks in advance!
Bob Thompson
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
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
Iugo 2021 年 3 月 1 日
Thank you both for your replies!!
I will do what Walter mentioned, create a TR.mat for each folder to store those values that I need for posterior calculations.

サインインしてコメントする。

回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeMatrix Indexing についてさらに検索

質問済み:

2021 年 2 月 27 日

コメント済み:

2021 年 3 月 1 日

Community Treasure Hunt

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

Start Hunting!

Translated by