Skip to content

Commit e3bc644

Browse files
committed
fixed simus for sub-aperture transmit (creatis-ULTIM#46), fixed InitialGuess (creatis-ULTIM#45)
1 parent 051458d commit e3bc644

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

src/pymust/simus.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,9 @@ def simus(*varargin):
353353
maxD = maxD + tp[-1] * param.c #add pulse length
354354

355355
#%-- FREQUENCY SAMPLES
356-
df = 1/2/(2*maxD/param.c + np.max(delaysTX.flatten() + param.RXdelay.flatten())) # % to avoid aliasing in the time domain
356+
valid_tx_delays = np.array([e for e in delaysTX.flatten() if not np.isnan(e)])
357+
df = 1/2/(2*maxD/param.c + np.max(np.concat((valid_tx_delays,param.RXdelay.flatten())))) # % to avoid aliasing in the time domain
358+
# df = 1/2/(2*maxD/param.c + np.max(delaysTX.flatten() + param.RXdelay.flatten())) # % to avoid aliasing in the time domain
357359
df = df*options.FrequencyStep
358360
Nf = 2*int(np.ceil(param.fc/df))+1 # % number of frequency samples
359361
#%-- Run PFIELD to calculate the RF spectra

src/pymust/smoothn.py

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -420,25 +420,28 @@ def RobustWeights(y,z,I,h,wstr):
420420
421421
"""
422422

423-
424423
# Initial Guess with weighted/missing data
425-
def InitialGuess(y,I):
424+
def InitialGuess(y, I):
426425
ny = y.shape[0]
427-
#%-- nearest neighbor interpolation (in case of missing values)
426+
#-- nearest neighbor interpolation (in case of missing values)
428427
if np.any(np.logical_not(I)):
429-
z = np.zeros_like(y)
428+
z = np.zeros_like(y)
430429
for i in range(ny):
431-
_,L = scipy.ndimage.distance_transform_edt(np.logical_not(I), return_indices = True)
430+
_, L = scipy.ndimage.distance_transform_edt(np.logical_not(I), return_indices=True)
432431
z[i] = y[i]
433-
#z[i][np.logical_not(I)] = y[i][*L[:,np.logical_not(I)]]; #Use np take
434-
z[i][np.logical_not(I)] = np.take(y[i], L[:, np.logical_not(I)])
432+
433+
# Fix: Flatten the indices to handle multidimensional arrays properly
434+
mask = np.logical_not(I)
435+
indices = tuple(L[j, mask] for j in range(L.shape[0]))
436+
z[i][mask] = y[i][indices]
435437
else:
436438
z = y
437439

438440
#-- coarse fast smoothing using one-tenth**d of the DCT coefficients
439-
z = scipy.fft.dctn(z, axes = np.arange(1, len(z.shape)))
440-
indices = np.indices(z.shape) / np.array(z.shape).reshape(([-1] + [1 for _ in range(z.ndim)])) #Normalised indices between 0 and 1
441-
maxIndex = np.max(indices, axis = 0)
442-
z[maxIndex >.1] = 0 # np.power(.1, 1/z.ndim) so that it has constant
443-
z = scipy.fft.idctn(z, axes = np.arange(1, len(z.shape)))
441+
z = scipy.fft.dctn(z, axes=np.arange(1, len(z.shape)))
442+
indices = np.indices(z.shape) / np.array(z.shape).reshape(([-1] + [1 for _ in range(z.ndim)]))
443+
maxIndex = np.max(indices, axis=0)
444+
z[maxIndex > .1] = 0
445+
z = scipy.fft.idctn(z, axes=np.arange(1, len(z.shape)))
444446
return z
447+

0 commit comments

Comments
 (0)