nipy / nipype

Workflows and interfaces for neuroimaging packages
https://nipype.readthedocs.org/en/latest/
Other
751 stars 530 forks source link

Custom color maps not working with ConvertScalarImageToRGB #3186

Open ThomasLieb opened 4 years ago

ThomasLieb commented 4 years ago

ConvertScalarImageToRGB works well with library colormaps, but the custom colormap feature doesn't display as expected. Perhaps extending documentation would clarify format requirements of the custom colormap file.

I am trying to discretize the colormap by interpolating an existing colormap as in the following:

`jet_cm = cm.get_cmap('jet')'
`new_map = jet_cm(np.linspace(0,1,20))`
`np.savetxt('custom_map.txt', new_map)`

The 'custom_map.txt' files is then used in the CreateTiledMosaic as follows:

`output_image = f'out_rgb.nii.gz'`
`converter = ConvertScalarImageToRGB()`
`converter.inputs.dimension = 3`
`converter.inputs.input_image = 'overlay.nii.gz'`
`converter.inputs.colormap = 'custom'`
`converter.inputs.maximum_input = 255`
`converter.inputs.minimum_input = 0`
`if cmap=='custom':`
    `converter.inputs.custom_color_map_file = 'custom_map.txt'`
`converter.inputs.output_image = output_image`
`converter.run()`

Is there a format requirement for the colormap file? The assumed format is rgba array.

Thanks for any help with the documentation.

effigies commented 4 years ago

I would suggest asking for help on the ANTs discussion list. Once you do figure it out, I agree it would be good to update the documentation here.