help > File name ordering for paired t-test
Showing 1-7 of 7 posts
Display:
Results per page:
May 27, 2016  01:05 PM | Matt Sutterer
File name ordering for paired t-test
Hi,

I'm looking to run a paired t-test comparing network structure between two scans in a set of 12 participants. I've designated the file names in the format of sub001_time01, sub001_time02, sub002_time01, etc. I'm familiar with setting up the GLM matrix for this from FSL, but in that case, you can specify the exact order of your input files. With NBS, since you're only indicating the first subject's correlation matrix, I'm wondering how the program reads in the list of subjects, and if I need to set up my design matrix for may paired test so that it will alternate between time one and time two for each subject, e.g.:

[1 0 1
 1 0 -1
 0 1 1
 0 1 -1]

instead of the way typically indicated in FSL or your help menu:

[1 0 1
 0 1 1
 1 0 -1
 0 1 -1]

since presumably the program will read in subject 1 time 1, then subject 1 time 2, and alternate from there, instead of reading in all subjects at time 1, and then all subjects at time 2? Is that correct?

Thanks,

Matt
May 27, 2016  11:05 PM | Andrew Zalesky
RE: File name ordering for paired t-test
Dear Matt,

Text files containing the connectivity matrices will be read in alpha-numerical order. In other words, they will be read by the NBS exactly as they appear when you open the directory with a file explorer (assuming the file explorer sorts files by alpha-numerical order).

You will need to adjust the rows of your design matrix to suit (as you describe below), or you may want to simply rename your files.

If you are still concerned about this, the safest option is to provide the connectivity matrices as a single Matlab (.mat) file stroring a 3D array, in which case you have full control of the ordering.

Happy to help if this is still unclear.

Andrew


Originally posted by Matt Sutterer:
Hi,

I'm looking to run a paired t-test comparing network structure between two scans in a set of 12 participants. I've designated the file names in the format of sub001_time01, sub001_time02, sub002_time01, etc. I'm familiar with setting up the GLM matrix for this from FSL, but in that case, you can specify the exact order of your input files. With NBS, since you're only indicating the first subject's correlation matrix, I'm wondering how the program reads in the list of subjects, and if I need to set up my design matrix for may paired test so that it will alternate between time one and time two for each subject, e.g.:

[1 0 1
 1 0 -1
 0 1 1
 0 1 -1]

instead of the way typically indicated in FSL or your help menu:

[1 0 1
 0 1 1
 1 0 -1
 0 1 -1]

since presumably the program will read in subject 1 time 1, then subject 1 time 2, and alternate from there, instead of reading in all subjects at time 1, and then all subjects at time 2? Is that correct?

Thanks,

Matt
Oct 25, 2017  05:10 PM | Sean Ma
RE: File name ordering for paired t-test
Hi Andrew, 

I'd like to follow up on this thread regarding how to check the loaded connectivity matrices files if they were read thru the file loader following the alpha-numerical order.

Is there a variable saved in the "nbs" cell structure that I can manually check upon the loaded files?

Thanks!

Sean
Oct 26, 2017  04:10 AM | Andrew Zalesky
RE: File name ordering for paired t-test
Hi Sean,

The "nbs" structure does not contain any info on the order in which the connectivity matrices were read in.

However, nbs.GLM.y will store the connectivity values in the order that they have been read in.

In particular, nbs.GLM.y is a matrix of dimensions number_of_subjects x connections, where connections denote the upper triangle elements of the connectivity matrix. Row 1 of this matrix is the first connectivity matrix, Row 2 is the second, etc. So, you can cross-check the values in nbs.GLM.y with the values in your connectivity matrices to determine the order in which they were read in.

Andrew

Originally posted by Sean Ma:
Hi Andrew, 

I'd like to follow up on this thread regarding how to check the loaded connectivity matrices files if they were read thru the file loader following the alpha-numerical order.

Is there a variable saved in the "nbs" cell structure that I can manually check upon the loaded files?

Thanks!

Sean
Oct 27, 2017  08:10 PM | Sean Ma
RE: File name ordering for paired t-test
Thanks, Andrew! 

Your answer is spot on. And just to elaborate more for others:
Each subject's upper diagonal matrix is read column-wise into a row vector in NBS.GLM.y (illustrated below) where each row should match to subject indicated in the design matrix NBS.GLM.x.

/ Subject 1's upper diagonal connectivity matrix \
| Subject 2's upper diagonal connectivity matrix  |
| ....     upper diagonal connectivity matrix  |
\ Subject N's upper diagonal connectivity matrix /

Thanks again!

Sean

Originally posted by Andrew Zalesky:
Hi Sean,

The "nbs" structure does not contain any info on the order in which the connectivity matrices were read in.

However, nbs.GLM.y will store the connectivity values in the order that they have been read in.

In particular, nbs.GLM.y is a matrix of dimensions number_of_subjects x connections, where connections denote the upper triangle elements of the connectivity matrix. Row 1 of this matrix is the first connectivity matrix, Row 2 is the second, etc. So, you can cross-check the values in nbs.GLM.y with the values in your connectivity matrices to determine the order in which they were read in.

Andrew

Originally posted by Sean Ma:
Hi Andrew, 

I'd like to follow up on this thread regarding how to check the loaded connectivity matrices files if they were read thru the file loader following the alpha-numerical order.

Is there a variable saved in the "nbs" cell structure that I can manually check upon the loaded files?

Thanks!

Sean
Apr 26, 2022  02:04 PM | Polona Pozeg
RE: File name ordering for paired t-test
Dear Andrew and other NBS users,

I would like to follow up on this topic in hope that this information will be useful for others as well.
I've recently discovered an error in my NBS analyses due to the order of how the matrices were read in, which gave me a big headache.

To detail the issue, my subject files were named as followed:
sub-ctrl001
sub-ctrl002
sub-ctrl00n
sub-PAT001
sub-PAT002
sub-PAT00n

Although the file explorer window within the NBS tool displayed the files in an alphanumerical order i.e., the ctrl subjects before the PAT subjects as listed above, I later found out that the PAT subjects were actually loaded first.
So apparently the alphanumerical sorting rules differ (i.e., the capitals come first or not) between how they are displayed in the NBS gui and how they are actually loaded later on.
So a warning for the user to check the nbs.GLM.y structure or even better, some sort of a design matrix review option (as in SPM) to check the order of loaded files would be a very helpful feature to avoid this in the future.

Best
Polona
Apr 27, 2022  01:04 AM | Andrew Zalesky
RE: File name ordering for paired t-test
Hi Polona, 

You raise an important point. Alphanumeric sorting can be counter intuitive. 

My understanding is that upper case (capitals) occur before lower case in alphanumeric order. Therefore, the PAT subjects should indeed be loaded in first. 

It avoid confusion, consider loading a mat file that comprises a three-dimensional matrix (nodes x nodes x subjects). in this way, we can be sure that the subjects are ordered in the desired order. Alternatively, it might be helpful to avoid using upper case letters in the file naming convention. 

We will consider adding a file order checker in future versions. 

best wishes, 
Andrew

Originally posted by Polona Pozeg:
Dear Andrew and other NBS users,

I would like to follow up on this topic in hope that this information will be useful for others as well.
I've recently discovered an error in my NBS analyses due to the order of how the matrices were read in, which gave me a big headache.

To detail the issue, my subject files were named as followed:
sub-ctrl001
sub-ctrl002
sub-ctrl00n
sub-PAT001
sub-PAT002
sub-PAT00n

Although the file explorer window within the NBS tool displayed the files in an alphanumerical order i.e., the ctrl subjects before the PAT subjects as listed above, I later found out that the PAT subjects were actually loaded first.
So apparently the alphanumerical sorting rules differ (i.e., the capitals come first or not) between how they are displayed in the NBS gui and how they are actually loaded later on.
So a warning for the user to check the nbs.GLM.y structure or even better, some sort of a design matrix review option (as in SPM) to check the order of loaded files would be a very helpful feature to avoid this in the future.

Best
Polona