help > Inputing Matrices
Showing 1-4 of 4 posts
Mar 25, 2015 09:03 PM | Dimitrios Palidis
Inputing Matrices
Hello Experts,
I already have my correlation matrices, I would like to use this toolbox to calculate graph metrics and run a GLM. I am having some trouble understanding the format of the matrices for input. For P ROI's and N subjects it is clear to produce a p x p x n matric but I am confused about the fourth dimension for indexing repeated measures.
Is it correct that I have a 3d matrix for each repeated measure (p x p x n) and that I combine each 3d matrix all along the fourth dimension into a single 4d matrix to use as my input?
Furthermore, I have 4 scans per subject. We ran a pair of scans pre training and a pair of scans post training. For each pair, the scans are immediately consecutive. I want to see the differences in graph metrics through training. It should be possible to set up my contrasts to do so in metalab?
Thanks for the help,
Dimitri
I already have my correlation matrices, I would like to use this toolbox to calculate graph metrics and run a GLM. I am having some trouble understanding the format of the matrices for input. For P ROI's and N subjects it is clear to produce a p x p x n matric but I am confused about the fourth dimension for indexing repeated measures.
Is it correct that I have a 3d matrix for each repeated measure (p x p x n) and that I combine each 3d matrix all along the fourth dimension into a single 4d matrix to use as my input?
Furthermore, I have 4 scans per subject. We ran a pair of scans pre training and a pair of scans post training. For each pair, the scans are immediately consecutive. I want to see the differences in graph metrics through training. It should be possible to set up my contrasts to do so in metalab?
Thanks for the help,
Dimitri
Mar 26, 2015 12:03 PM | Jeffrey Spielberg
RE: Inputing Matrices
Hi Dmitri,
Yes, you would combine your p x p x n matrices along the fourth dimension to set up the repeated measures. So, something like conmats = cat(4,premats,post mats); This should give you a p x p x n x r matrix (p = #nodes, n = #participants, r = #repeated levels).
Yes, you can test whether there are pre-post training differences in graph metrics by setting the training factor up as the repeated measure. One question, do you have 2 contrast matrices per participant (i.e., 1 pre, 1 post) or 4 (i.e., 2 pre, 2 post)? If you have 2, that's fine. If you have four, you'll likely want to combine them somehow, unless you want to model differences between all the scans…. If you do want to look at differences across 4 levels, note that repeated measures are performed with polynomial contrasts, so you should concatenate levels/interpret accordingly.
Best,
Jeff
Yes, you would combine your p x p x n matrices along the fourth dimension to set up the repeated measures. So, something like conmats = cat(4,premats,post mats); This should give you a p x p x n x r matrix (p = #nodes, n = #participants, r = #repeated levels).
Yes, you can test whether there are pre-post training differences in graph metrics by setting the training factor up as the repeated measure. One question, do you have 2 contrast matrices per participant (i.e., 1 pre, 1 post) or 4 (i.e., 2 pre, 2 post)? If you have 2, that's fine. If you have four, you'll likely want to combine them somehow, unless you want to model differences between all the scans…. If you do want to look at differences across 4 levels, note that repeated measures are performed with polynomial contrasts, so you should concatenate levels/interpret accordingly.
Best,
Jeff
Mar 27, 2015 12:03 AM | Dimitrios Palidis
RE: Inputing Matrices
Dear Jeff,
Thanks you for the reply.
I have 4 matrices per subject (2 pre, 2 post). I have tried converting the correlations to Z-scores, averaging them (for each pair), and then converting the average z-scores back to correlation coefficients to yield 2 matrices per subject. I then used paired t-test to compare pre and post. I am not sure if this approach is correct, which is one reason I hoped to avoid this averaging by using a GLM. I do not want to model differences between all the scans, just between the pre and post conditions. (for each condition we acquired 2 immediately consecutive scans, to gather more data).
Thanks again,
Dimitri
Thanks you for the reply.
I have 4 matrices per subject (2 pre, 2 post). I have tried converting the correlations to Z-scores, averaging them (for each pair), and then converting the average z-scores back to correlation coefficients to yield 2 matrices per subject. I then used paired t-test to compare pre and post. I am not sure if this approach is correct, which is one reason I hoped to avoid this averaging by using a GLM. I do not want to model differences between all the scans, just between the pre and post conditions. (for each condition we acquired 2 immediately consecutive scans, to gather more data).
Thanks again,
Dimitri
Mar 27, 2015 12:03 PM | Jeffrey Spielberg
RE: Inputing Matrices
Hi Dimitri,
As the toolbox is currently setup, you'll need to combine the 2 matrices for each condition if you want to use repeated measures. However, that should be fine, because averaging the matrices beforehand will have much the same effect as combining them in a GLM, unless one of the scans is, on average (i.e., across participants), much more variable (because the GLM would take that variability into account).
You don't need to z-score the correlations before averaging them, as correlations have the same scale (you might want to try it both ways to see if it matters).
When I have 2+ scans for the same condition (or 2+ resting state runs), I typically combine them before creating the correlation matrices (i.e., concatenating the timeseries). In principle, it shouldn't matter much whether you concatenate timeseries or average correlations, but in practice it may have an impact.
If you do want to concatenate the timeseries, you will likely want to either 1) mean center each timeseries before concatenating (to avoid mean signal differences between runs driving the correlation) or 2) zscore each timeseries before concatenating (to also avoid one of the timeseries driving the correlation, if it has higher variance). I usually just mean center, but either one should be ok.
BTW, I include a script that concatenates timeseries (concat_timeseries.m in the 'extra' folder). However, the script assumes that you've done preprocessing in the GTG toolbox (i.e., it assumes the data are in a certain format), so it's probably easier to just do it yourself.
Best,
Jeff
As the toolbox is currently setup, you'll need to combine the 2 matrices for each condition if you want to use repeated measures. However, that should be fine, because averaging the matrices beforehand will have much the same effect as combining them in a GLM, unless one of the scans is, on average (i.e., across participants), much more variable (because the GLM would take that variability into account).
You don't need to z-score the correlations before averaging them, as correlations have the same scale (you might want to try it both ways to see if it matters).
When I have 2+ scans for the same condition (or 2+ resting state runs), I typically combine them before creating the correlation matrices (i.e., concatenating the timeseries). In principle, it shouldn't matter much whether you concatenate timeseries or average correlations, but in practice it may have an impact.
If you do want to concatenate the timeseries, you will likely want to either 1) mean center each timeseries before concatenating (to avoid mean signal differences between runs driving the correlation) or 2) zscore each timeseries before concatenating (to also avoid one of the timeseries driving the correlation, if it has higher variance). I usually just mean center, but either one should be ok.
BTW, I include a script that concatenates timeseries (concat_timeseries.m in the 'extra' folder). However, the script assumes that you've done preprocessing in the GTG toolbox (i.e., it assumes the data are in a certain format), so it's probably easier to just do it yourself.
Best,
Jeff