I just re-read your email - if you want to retain the values for each
of your identified voxels, just add the voxel values as an extra
column to the text file, and change the loop to:
----
for x, y, z, val in voxels:
mask[x, y, z] = val
----
Paul
On Wed, Jan 7, 2015 at 10:41 AM, paul mccarthy <[log in to unmask]> wrote:
> Hi Ralph,
>
> The easiest way to do this (from my point of view) would be to
> programmatically create a mask image in your language of choice (e.g.
> matlab, python). In Python, assuming that you have numpy and nibabel
> installed:
>
> ----
> #!/usr/bin/env python
>
> import numpy as np
> import nibabel as nib
>
> # voxel_coords.txt contains a list of voxels,
> # one line per voxel, with each line containing
> # space separated x y z coordinates
> voxels = np.loadtxt('voxel_coords.txt')
>
> # use the appropriate image dimensions here
> mask = np.zeros((91, 109, 91))
>
> for x, y, z in voxels:
> mask[x, y, z] = 1
>
> image = nib.nifti1.Nifti1Image(mask, np.identity(4))
>
> nib.save(image, 'mask.nii.gz')
> ----
>
> After you have created your mask image with the above script (or
> similar), you can use fslcpgeom to copy the voxel geometry/affine
> transformation information from your original file to the mask file.
>
> Cheers,
>
> Paul
>
> On Wed, Jan 7, 2015 at 10:11 AM, Ralph Brecheisen
> <[log in to unmask]> wrote:
>> Hi,
>>
>> I have a list of voxel values and positions which I'd like to visualize in FSLView, either overlaid on top of another anatomical image or just the voxel values. I want to verify that the voxels are clustered together and not dispersed all across the brain. I obtained these voxels by applying a recursive feature elimination (using SVMs) on a large group of case-controls. I'd like to verify whether the voxels selected correspond to regions in the brain that are known to be associated with the disease I'm investigating (schizophrenia). Or at least, they should be grouped together.
>>
>> I looked at the various FSL tools (especially FSLUtils) but could not find any that allows me to do the above. I initially tried to run fsl2ascii on an existing nifti image, change the voxel values and then convert back to nifti using fslascii2img but the latter tool keeps complaining about the nr. voxels not matching the number of values in the text file, which is strange because I got the voxel dimensions from fslinfo. They should match....
>>
>> Any ideas on how to proceed with this?
>>
>> Regards,
>>
>> Ralph
|