Extract preprocessed image and mask from Pyradiomics

Dear community,

I was wondering if it is possible to extract the images and masks on which the feature calculation is based with Pyradiomics in command-line batch mode. I would like to make some comparisons on different mask validation, image discretization, and normalization procedures.

Best,
Jonas

Hello Jonas,

Currently, it is not possible to do so directly from the commandline. Still, PyRadiomcis is built fairly modular, so it shouldn’t be to much of a hassle to use the pre-processing functions directly.

Image pre-processing (e.g. normalization, resampling and application of filters) is all defined in imageoperations.py. Every functions accepts a **kwargs argument dict, which contains all configuration from the setting section in the parameter file (it doesn’t matter if there are settings in the dict that are intended for other functions, it just takes out those that are needed).

Image discretization is just as easy, but works on the numpy array extracted from the image. The function you’re looking for is imageoperations.binImage, which accepts the image_array, an optional mask_array and the **kwargs settings. In case the mask array (boolean array) is provided, the discretization is based only on the pixels inside the ROI (PyRadiomics default). If omitted, the entire image is discretized. Be aware that the selection of the label is done elsewhere, the mask array should have boolean datatype indicating only the active ROI.

Hope this helps.

Regards,

Joost

1 Like

Thank you very much @JoostJM.
Does that mean I need to integrate this into my code or apply imageoperations.py from command line?

Best,
Jonas

Hello @JonasB,

To test this, you’d need to integrate it into your own python script. The PyRadiomics commandline does not expose that functionality.

Regards,

Joost

Hi @JoostJM ,

thanks for your answers.
I managed to transform the images.
I was wondering, since the functions (such as imageoperations.getLoGImage) take the image and the segmentations but only output the transformed img could the segmentation (the region of interest) be effected by the transformation?
Or in other words do we need to refine the mask for transformed images (might be that the borders of the segmentation from the original image do not fit 100% on the transformed image)?

Best regards,
Jonas