Error using reshape

46 views
Skip to first unread message

vrlab.su...@gmail.com

unread,
Oct 24, 2018, 9:36:00 AM10/24/18
to GLMdenoise
Hi there,

My name is Heather and I'm looking to denoise my data ahead of a MVPA analysis with leave-one-run-out cross-validation. Since I want my runs to remain independent, I've tried running GLMdenoise on each individual run. However, I get the following error message:

Error using reshape
To RESHAPE the number of elements must not change.

Error in GLMpredictresponses (line 110)
responses{p} = reshape((temp * squish(model{2},dimdata)')',[xyzsize
numtimepoints(p)]); % X x Y x Z x time

Error in GLMestimatemodel (line 460)
modelfit(p) =
GLMpredictresponses(results{p},{design{p}},tr,size(data2{p},1),1); % 1 because
results{p} is in flattened format

Error in GLMdenoisedata (line 641)
xvalfit = GLMestimatemodel(design,data,stimdur,tr,'assume',hrf,-1,opt,[],1);

Error in OBE01Run2 (line 53)
[results,denoiseddata] =
GLMdenoisedata(design,data,stimdur,tr,[],[],[],'Ppt01FiguresRun2');


GLMdenoise runs fine if all runs are included, so I'm not quite sure why reshape becomes an error if the analysis is divided into runs. Does anyone have an idea of what's going wrong here and how to rectify the issue? Any insight is much appreciated.

Best,
Heather

Kendrick Kay

unread,
Oct 24, 2018, 9:44:28 AM10/24/18
to vrlab.su...@gmail.com, GLMdenoise
Hi Heather,



My name is Heather and I'm looking to denoise my data ahead of a MVPA analysis with leave-one-run-out cross-validation. Since I want my runs to remain independent, I've tried running GLMdenoise on each individual run. However, I get the following error message:

Error using reshape
To RESHAPE the number of elements must not change.

Error in GLMpredictresponses (line 110)
     responses{p} = reshape((temp * squish(model{2},dimdata)')',[xyzsize
     numtimepoints(p)]);  % X x Y x Z x time

Error in GLMestimatemodel (line 460)
   modelfit(p) =
   GLMpredictresponses(results{p},{design{p}},tr,size(data2{p},1),1);  % 1 because
   results{p} is in flattened format

Error in GLMdenoisedata (line 641)
   xvalfit = GLMestimatemodel(design,data,stimdur,tr,'assume',hrf,-1,opt,[],1);

Error in OBE01Run2 (line 53)
[results,denoiseddata] =
GLMdenoisedata(design,data,stimdur,tr,[],[],[],'Ppt01FiguresRun2');


Hmm, GLMdenoise (in its current form) can only be run with at least two runs (because it tries to use run-based cross-validation to figure out how many noise regressors to include).  So, trying to run it on individual runs will not work....

You could try running GLMdenoise on n-1 runs and then just using the results to apply to the nth run?

Also, GLMestimatemodel.m might be a useful function for you (it is the innards of GLMdenoisedata, but without the attempt to do the denoising).



GLMdenoise runs fine if all runs are included, so I'm not quite sure why reshape becomes an error if the analysis is divided into runs. Does anyone have an idea of what's going wrong here and how to rectify the issue? Any insight is much appreciated.

To troubleshoot if you could tell me the sizes of the inputs, e.g.:
  cellfun(@(x) disp(size(x)),design)
  cellfun(@(x) disp(size(x)),data)
  stimdur
  tr
that could help me diagnose.

Kendrick


--
Kendrick Kay, PhD
Assistant Professor
Center for Magnetic Resonance Research (2-116)
University of Minnesota, Twin Cities
   Web: http://cvnlab.net
E-mail: k...@umn.edu
  Cell: 510-206-1059
 Skype: kendrickkay

vrlab.su...@gmail.com

unread,
Oct 26, 2018, 5:52:09 AM10/26/18
to GLMdenoise
Hi Kendrick,

Thank you for the super speedy reply! Interesting idea to run denoising on n-1 runs and apply results to the left out run. However, I'm concerned that the noise from one run might not actually match noise from a separate run (e.g. if a participant moves more / in a different direction in one run vs. another).

Here are the input sizes:
data = 104 104 72 359
design = 359 4
stimdur = 6.4
tr = 0.8

Best,
Heather

Kendrick Kay

unread,
Oct 26, 2018, 11:20:00 AM10/26/18
to vrlab.su...@gmail.com, GLMdenoise
Hi Heather,


> Thank you for the super speedy reply! Interesting idea to run denoising on n-1 runs and apply results to the left out run. However, I'm concerned that the noise from one run might not actually match noise from a separate run (e.g. if a participant moves more / in a different direction in one run vs. another).

Right, that is a general issue. But, I think the logic is still valid -- suppose you get better (denoised) beta estimates from n-1 runs. Even if you don't attempt to denoise the nth run, the beta estimates from the n-1 runs should generalize (predict) better, on average, to the nth run (even if you don't do anything fancy in trying to denoise the nth run). In fact, that logic is at the heart of how GLMdenoise decides the number of noise regressors to add in...



>
> Here are the input sizes:
> data = 104 104 72 359
> design = 359 4
> stimdur = 6.4
> tr = 0.8


So, can you confirm that your data are like:

data is { [104x104x72x359] [104x104x72x359] ... }
design is { [359x4] [359x4] ... }

such that both data and design are cell vectors with number of elements equal to the number of fMRI runs that you conducted?



Kendrick

Reply all
Reply to author
Forward
0 new messages