Hello Bob,
thanks for your comments; see below.
bob cox wrote:
> When we have wanted to do "moving spotlight" computations
> across the whole brain volume, we have written special programs
> for these purposes, since the calculations take a long long
> time. Two such programs are 3dLocalstat and 3dLocalSVD -- the
> first computes various statistics in a neighborhood around each
> voxel, and the second computes the first principal component
> vector of the collection of time series vectors from each
> neighborhood. The idea of extracting the neighborhood values
> into many external files and processing them outside AFNI
> programs proper didn't even occur to me, since it would be very
> slow.
I agree, that would be very slow. I was not suggesting to extract neighbourhood values to external files but only to save the masks. And this suggestion was intentionally very naive/'stupid' to illustrate my need for sparse mask representations.
> If you are facile with C, you might consider adapting one of
> these programs to your needs. They have the code needed to
> extract values from neighborhoods, respecting a mask (if
> supplied). The primary difference between 3dLocalstat and
> 3dLocalSVD is that the first program processes each
> neighborhood one volume at a time, while the second processes
> each neighborhood as a collection of time series.
Thanks for pointing me to these programs, but my needs are slightly different. Besides circular masks, I also generate masks based on grey matter selection and some other critera. This implementation is more complicated (and time consuming) but works well in matlab. To be clear, I'm not looking for a replacement for ROI selection, only for an efficient (as in storage space needed) way to save these ROI selections to be used for the classifications, which I would like to make independent of the voxel selection. Hopefully this will allow for speeding up the classification by using a faster language (C), the GPU and/or grid computing *and* without relying on matlab for classifications (we have a limited number of licenses) as information mapping is embarrassingly parallel.
Nevertheless, thanks for your helpful comments. I will then start on some file format representation of sparse masks. An initial idea is the following (probably very naive, so suggestions are welcome):
- all values are stored as 4 byte integers; that should be enough assuming we don't have crazy big files.
- we have a hierarchy of "blocks", "ROI masks", and "voxel indices". Each block contains ROIs, and each ROI contains voxel indices.
Specific data organization:
- the file starts with number of ROIs and the maximum number of voxels over all ROIs. In that way we can easily allocate the necessary memory space.
- this is followed by the number of "blocks" N, followed by N numbers that represent the end position of each "block", followed by N "blocks". This allows for easy parallelizing the classification, as different programs can "jump" in the file to a certain block.
- the i-th "block" starts with the number of ROIs mask P(i), followed by P(i) numbers C(i,j) that represent the number of voxels in each ROI mask, followed by P(i) "ROI masks".
- the j-th "ROI mask" in the i-th block contains C(i,j) linear indices that refer to the voxels in the volume.
For 1e5 masks with 100 voxels each, this would result in files of around 4*100*1e5=40MB.
What do you think?
thanks again,
Nick