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.
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.
Thank you very much @JoostJM.
Does that mean I need to integrate this into my code or apply imageoperations.py from command line?
To test this, you’d need to integrate it into your own python script. The PyRadiomics commandline does not expose that functionality.