@@ -173,12 +173,32 @@ def __init__(
173173 prob : float = 0.1 ,
174174 mean : Sequence [float ] | float = 0.0 ,
175175 std : Sequence [float ] | float = 1.0 ,
176- degrees_of_freedom : int = 64 , #64 default because typical modern brain MRI is 32 quadrature coils
176+ degrees_of_freedom : int = 64 , # 64 default because typical modern brain MRI is 32 quadrature coils
177177 channel_wise : bool = False ,
178178 relative : bool = False ,
179179 sample_std : bool = True ,
180180 dtype : DtypeLike = np .float32 ,
181181 ) -> None :
182+ """
183+ Initializes the transform.
184+
185+ Args:
186+ prob: Probability to add noise.
187+ mean: Mean of the Gaussian noise distributions.
188+ std: Standard deviation (spread) of the Gaussian noise distributions.
189+ degrees_of_freedom: Number of Gaussian distributions (degrees of freedom).
190+ `degrees_of_freedom=2` is Rician noise. Defaults to 64 (32 quadrature coils).
191+ channel_wise: If True, treats each channel of the image separately.
192+ relative: If True, the spread of the sampled Gaussian distributions will
193+ be std times the standard deviation of the image or channel's intensity
194+ histogram.
195+ sample_std: If True, sample the spread of the Gaussian distributions
196+ uniformly from 0 to std.
197+ dtype: output data type, if None, same as input image. defaults to float32.
198+
199+ Raises:
200+ ValueError: If `degrees_of_freedom` is not an integer or is less than 1.
201+ """
182202 RandomizableTransform .__init__ (self , prob )
183203 self .prob = prob
184204 self .mean = mean
@@ -192,6 +212,23 @@ def __init__(
192212 self .dtype = dtype
193213
194214 def _add_noise (self , img : NdarrayOrTensor , mean : float , std : float , k : int ):
215+ """
216+ Applies non-central chi noise to a single image or channel.
217+
218+ This method generates `k` Gaussian noise arrays, adds the input `img`
219+ to the first one (as the non-centrality component), and then computes
220+ the square root of the sum of squares.
221+
222+ Args:
223+ img: Input image array.
224+ mean: Mean for the Gaussian noise distributions.
225+ std: Standard deviation for the Gaussian noise distributions.
226+ k: Degrees of freedom (number of noise arrays).
227+
228+ Returns:
229+ Image with non-central chi noise applied, with the same
230+ backend (Numpy/Torch) as the input.
231+ """
195232 dtype_np = get_equivalent_dtype (img .dtype , np .ndarray )
196233 im_shape = img .shape
197234 _std = self .R .uniform (0 , std ) if self .sample_std else std
0 commit comments