Skip to content

Commit

Permalink
Merge pull request #286 from deepanshs/apodization_bug
Browse files Browse the repository at this point in the history
fixed 0Hz bug in apodization
  • Loading branch information
mVenetos97 authored Jul 11, 2023
2 parents 0769b8d + ded33fc commit 71c606d
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/mrsimulator/signal_processor/apodization.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,11 @@ def str_to_quantity(cls, v, values):
def fn(self, x):
x = self.get_coordinates_in_units(x, unit=1.0 / self.property_units["FWHM"])
sigma = self.FWHM / 2.354820045030949
return 1.0 if self.FWHM == 0.0 else np.exp(-2.0 * (np.pi * sigma * x) ** 2)
return (
np.ones_like(x)
if self.FWHM == 0.0
else np.exp(-2.0 * (np.pi * sigma * x) ** 2)
)


class Exponential(Apodization):
Expand Down Expand Up @@ -175,7 +179,11 @@ def str_to_quantity(cls, v, values):

def fn(self, x):
x = self.get_coordinates_in_units(x, unit=1.0 / self.property_units["FWHM"])
return 1.0 if self.FWHM == 0.0 else np.exp(-self.FWHM * np.pi * np.abs(x))
return (
np.ones_like(x)
if self.FWHM == 0.0
else np.exp(-self.FWHM * np.pi * np.abs(x))
)


class SkewedGaussian(Apodization):
Expand Down Expand Up @@ -240,7 +248,7 @@ def fn(self, x):
prob_func = [np.exp(-(0.5) * (sigma * j) ** 2) for j in x]
cum_prob_func = [0.5 + 0.5 * erf(self.skew * j / np.sqrt(2)) for j in x]
sg = np.asarray([a * b for a, b in zip(prob_func, cum_prob_func)])
return 1.0 if self.skew == 0.0 else sg
return np.ones_like(x) if self.FWHM == 0.0 else sg


class TopHat(Apodization):
Expand Down

0 comments on commit 71c606d

Please sign in to comment.