ANTsX / ANTsR

R interface to the ANTs biomedical image processing library
https://antsx.github.io/ANTsR
Apache License 2.0
127 stars 35 forks source link

How to save indices of column in timeseries2matrix function #335

Closed prateeksasan1 closed 3 years ago

prateeksasan1 commented 3 years ago

Hi,

I am trying to convert a 4-d image to a matrix using a mask using timeseries2matrix. I am also interested in noting what part of the mask corresponds to what column. Is it possible?

For e.g 4-d image is of dimension 90100801200 (1200 is the time point) and i have a 3-d binary mask (dim = 90100*80) with sum(mask) = 150

The output of timeseries2matrix would be a matrix of size 1200 * 150.

I want to know which indices of the mask the columns correspond to. i.e 1st column is mask index (1, 4, 5) , 2nd is (1, 4, 6) etc.

Is there an easy way to do this. I see in your code that you subset the image which makes it a vector and then turn it into a matrix but couldnt figure out how to get the indices

stnava commented 3 years ago

use antsGetNeighborhood* functionality with radius=0 .... read the documentation

brian

On Mon, Dec 7, 2020 at 3:05 PM Prateek Sasan notifications@github.com wrote:

Hi,

I am trying to convert a 4-d image to a matrix using a mask using timeseries2matrix. I am also interested in noting what part of the mask corresponds to what column. Is it possible?

For e.g 4-d image is of dimension 9010080 1200 (1200 is the time point) and i have a 3-d binary mask (dim = 90100*80) with sum(mask) = 150

The output of timeseries2matrix would be a matrix of size 1200 * 150.

I want to know which indices of the mask the columns correspond to. i.e 1st column is mask index (1, 4, 5) , 2nd is (1, 4, 6) etc.

Is there an easy way to do this. I see in your code that you subset the image which makes it a vector and then turn it into a matrix but couldnt figure out how to get the indices

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ANTsX/ANTsR/issues/335, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACPE7TE42WHHP6GI2OKTETSTUYQLANCNFSM4UQ6NM6Q .

prateeksasan1 commented 3 years ago

Thanks. I was not aware of this function.

Using getNeighborhoodInMask with spatial.info = TRUE, the 2nd matrix in the list gave me the indices. Awesome. Thanks a lot

Prateek Sasan