fepegar / resector

Algorithm to simulate resection surgery on brain MRI scans. Published in MICCAI 2020, extended in IJCARS.
https://doi.org/10.1007/s11548-021-02420-2
MIT License
13 stars 4 forks source link

meaning of sigma and radii inputs #9

Closed cclaess closed 2 years ago

cclaess commented 2 years ago

I am trying to use the resector.resect() function in python, where I want to cache all the inputs on beforehand (I need a new resection in every epoch of my model, and don't want to use imread for every instance of that). I mentioned that I can generate the gray matter and resectable masks from resector.parcellation. However, the python function also requires the inputs "sigma" and "radii". I am not sure what these parameters mean, and how I can generate them if necessary?

fepegar commented 2 years ago

Hi, @CrisClaessens. I agree the documentation is not great. Contributions are welcome!

I'm not sure what imread is.


sigmas should be a sequence of three floats >= 0:

https://github.com/fepegar/resector/blob/59231e72e639cae4b2de10d0ea393680522cc80a/resector/random_resection.py#L194-L195

They represent the standard deviation across each dimension of the Gaussian kernels used to smooth the masks for the alpha blending, to simulate partial-volume effects, in mm.

https://github.com/fepegar/resector/blob/59231e72e639cae4b2de10d0ea393680522cc80a/resector/texture.py#L104-L113

Screenshot from 2021-10-29 13-36-59

More information in the ITK docs for SmoothingRecursiveGaussianImageFilter.


radii should be a sequence of three floats > 0. They are the three semi-axes of the ellipsoid used to model the cavity, in mm.

https://github.com/fepegar/resector/blob/59231e72e639cae4b2de10d0ea393680522cc80a/resector/mesh.py#L109-L124

cclaess commented 2 years ago

@fepegar Thanks a lot! So if I understand correctly, you would want to choose different values for these every time you are generating a different resection in the same image? In the case I am correct, what are the ranges of these vectors that are used when I just use resect t1.nii.gz gif_parcellation.nii.gz t1_resected.nii.gz t1_resection_label.nii.gz in the command prompt?

fepegar commented 2 years ago

resect uses the RandomResection transform:

https://github.com/fepegar/resector/blob/59231e72e639cae4b2de10d0ea393680522cc80a/resector/cli/resect.py#L80-L83

whose default values for its kwargs can be found in the code:

https://github.com/fepegar/resector/blob/59231e72e639cae4b2de10d0ea393680522cc80a/resector/random_resection.py#L22-L40

In this hard-coded implementation, the sigmas will be sampled from a uniform distribution U(0.5, 1), but the radii are computed from the volume and the radii ratios, which are also sampled. All the information is in the open-access paper:

𝑇S(π‘Ÿπ‘Ÿ) is a scaling transform, where (π‘Ÿ1,π‘Ÿ2,π‘Ÿ3)=π‘Ÿπ‘Ÿ are semiaxes of an ellipsoid with volume v used to model the cavity shape. The semiaxes are computed as π‘Ÿ1=π‘Ÿ, π‘Ÿ2=πœ†π‘Ÿ and π‘Ÿ3=π‘Ÿ/πœ†, where π‘Ÿ=(3𝑣/4)1/3 and πœ† controls the semiaxes length ratios.Footnote1 These transforms are applied to 𝑉𝛿 to define the initial resection cavity surface 𝑆E={𝑉E,𝐹}, where 𝑉E={𝑇S(π‘Ÿπ‘Ÿ)βˆ˜π‘‡R(πœƒπœƒr)(𝑣𝑣𝛿𝑖)}𝑛𝑉𝑖=1.

cclaess commented 2 years ago

@fepegar Sorry I did not find that myself. This helps a lot, thanks!

fepegar commented 2 years ago

No worries!