I'm trying to perform a 'moving accumulation' (the best descriptor I can think of at the moment). I think similar to '3dcalc -accumulate' but I want to do this discretely. For example, I would like to sum every two values along time. And repeat the calculation for all 3D. In matlab, the most simple, equivalent command I could think of for a single timeseries was (timeseries of 190 points):
sum(reshape(timeseries,2,95))
I read through the 3dcalc documentation and could not clearly see how this could be done. Any guidance or help with this would be greatly appreciated. Thank you!
Thank you very much for answering this! I have a question about the 3dcalc operation:
I don’t to repeat indices if they’ve already been summed. e.g. I want to only sum points 1 & 2, then 3 &4, 5& 6, and so on. Not 1 & 2, then 2&3, then 3&4, etc. as is done in the above setting. Thus my new data set would have a reduced time length of n_t/2 where n_t is the number of time points in the original data set. In the 3dcalc, is it possible to make the ‘b’ data set to be ‘2*a-l’. That is an invalid operation, I’ve come to find, but something like that would be great.
I suppose I could try to collect every 2nd point of the output data set from the above command you listed with 3dcalc, but I’m not sure how to do that either.
3dcalc -a epi_r1+'orig[0..(2)]' -b epi_r1+'orig[1..(2)]' -expr 'a+b' -prefix rm_3dcalc_sum2.nii.gz -overwrite
I might eventually want to sum ever 3 or 4 points together which I can add variables 'c' and 'd' and the adjusted above notation to do it. But if there's any more simple way to do it, would be interested to know. Thank you again for your time!
It occurred to me after I posted that you might really want something like that instead. You can extract every other volume (either evens or odds) from the first method’s results, or do the extraction all within 3dcalc in one step. Averaging and differences this way are relatively simple. Similar kinds of commands are often needed for ASL processing:
Ah, thank you for the link! I do very much appreciate that.
All the best!
Edwin
The
National Institute of Mental Health (NIMH) is part of the National Institutes of
Health (NIH), a component of the U.S. Department of Health and Human
Services.