Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def merge_view_horz(volume, dx, dy):
junctions = []
# creating merged volume
merge_vol = np.zeros((volume.shape[0], volume.shape[1]))
# creating vector for processing along cols (one row)
amplitude = np.zeros(
(volume.shape[0], volume.shape[2])
) # 1 if it is vertical 0 if the bars are horizontal
y = np.linspace(
0, 0 + (volume.shape[0] * dy), volume.shape[0], endpoint=False
) # definition of the distance axis
# x = np.arange(0,) #definition of the distance axis
# merging the two images together
ampl_resamp = np.zeros(((volume.shape[0]) * 10, volume.shape[2]))
# amp_peak = np.zeros((volume.shape[0]) * 10)
for item in tqdm(range(0, volume.shape[2])):
diag_stack[3] = (
diag_stack[3]
+ volume[
int(np.shape(volume)[0] / 2) + j,
int(np.shape(volume)[1] / 2) - j,
i,
]
)
volume_resort[:, :, np.argmax(diag_stack)] = volume[:, :, i]
# creating merged volumes
merge_vol = np.zeros((volume_resort.shape[0], volume_resort.shape[1]))
# creating vector for processing (1 horizontal & 1 vertical)
amplitude_horz = np.zeros(
(volume_resort.shape[1], volume_resort.shape[2])
) # 1 if it is vertical 0 if the bars are horizontal
amplitude_vert = np.zeros((volume_resort.shape[0], volume_resort.shape[2]))
y = np.linspace(
0, 0 + (volume_resort.shape[0] * dy), volume_resort.shape[0], endpoint=False
) # definition of the distance axis
x = np.linspace(
0, 0 + (volume_resort.shape[1] * dy), volume_resort.shape[1], endpoint=False
) # definition of the distance axis
ampl_resamp_y1 = np.zeros(
((volume_resort.shape[0]) * 10, int(volume_resort.shape[2] / 2))
)
ampl_resamp_y2 = np.zeros(
((volume_resort.shape[0]) * 10, int(volume_resort.shape[2] / 2))
junctions = []
# creating merged volume
merge_vol = np.zeros((volume.shape[0], volume.shape[1]))
# creating vector for processing along cols (one row)
amplitude = np.zeros(
(volume.shape[0], volume.shape[2])
) # 1 if it is vertical 0 if the bars are horizontal
y = np.linspace(
0, 0 + (volume.shape[0] * dy), volume.shape[0], endpoint=False
) # definition of the distance axis
# merging the two images together
ampl_resamp = np.zeros(((volume.shape[0]) * 10, volume.shape[2]))
for slice in tqdm(range(0, volume.shape[2])):
merge_vol = merge_vol + volume[:, :, slice]
amplitude[:, slice] = volume[:, int(volume.shape[1] / 2), slice]
ampl_resamp[:, slice] = signal.resample(
amplitude[:, slice], int(len(amplitude)) * 10
) # resampling the amplitude vector
fig, ax = plt.subplots(nrows=2, squeeze=True, figsize=(6, 8))
extent = (0, 0 + (volume.shape[1] * dx), 0, 0 + (volume.shape[0] * dy))
ax[0].imshow(merge_vol, extent=extent, aspect="auto")
ax[0].set_xlabel("x distance [mm]")
ax[0].set_ylabel("y distance [mm]")
) # 1 if it is vertical 0 if the bars are horizontal
amplitude_vert = np.zeros((volume_resort.shape[0], volume_resort.shape[2]))
# y = np.linspace(0, 0 + (volume_resort.shape[0] * dy), volume_resort.shape[0],
# endpoint=False) # definition of the distance axis
# x = np.linspace(0, 0 + (volume_resort.shape[1] * dy), volume_resort.shape[1],
# endpoint=False) # definition of the distance axis
ampl_resamp_y1 = np.zeros(
((volume_resort.shape[0]) * 10, int(volume_resort.shape[2] / 2))
)
ampl_resamp_y2 = np.zeros(
((volume_resort.shape[0]) * 10, int(volume_resort.shape[2] / 2))
)
ampl_resamp_x1 = np.zeros(
((volume_resort.shape[1]) * 10, int(volume_resort.shape[2] / 2))
)
ampl_resamp_x2 = np.zeros(
((volume_resort.shape[1]) * 10, int(volume_resort.shape[2] / 2))
)
amplitude_horz[:, 0] = volume_resort[
int(volume_resort.shape[0] / 3.25), :, 0
] # for profile 1
amplitude_horz[:, 1] = volume_resort[
int(volume_resort.shape[0] / 3.25), :, 1
] # for profile 1
amplitude_horz[:, 3] = volume_resort[
int(volume_resort.shape[0]) - int(volume_resort.shape[0] / 3.25), :, 2
] # the numbers here are reversed because we are going to slide the second graph (the overlay) to minimize the error #for profile 2
amplitude_horz[:, 2] = volume_resort[
# y = np.linspace(0, 0 + (volume_resort.shape[0] * dy), volume_resort.shape[0],
# endpoint=False) # definition of the distance axis
# x = np.linspace(0, 0 + (volume_resort.shape[1] * dy), volume_resort.shape[1],
# endpoint=False) # definition of the distance axis
ampl_resamp_y1 = np.zeros(
((volume_resort.shape[0]) * 10, int(volume_resort.shape[2] / 2))
)
ampl_resamp_y2 = np.zeros(
((volume_resort.shape[0]) * 10, int(volume_resort.shape[2] / 2))
)
ampl_resamp_x1 = np.zeros(
((volume_resort.shape[1]) * 10, int(volume_resort.shape[2] / 2))
)
ampl_resamp_x2 = np.zeros(
((volume_resort.shape[1]) * 10, int(volume_resort.shape[2] / 2))
)
amplitude_horz[:, 0] = volume_resort[
int(volume_resort.shape[0] / 3.25), :, 0
] # for profile 1
amplitude_horz[:, 1] = volume_resort[
int(volume_resort.shape[0] / 3.25), :, 1
] # for profile 1
amplitude_horz[:, 3] = volume_resort[
int(volume_resort.shape[0]) - int(volume_resort.shape[0] / 3.25), :, 2
] # the numbers here are reversed because we are going to slide the second graph (the overlay) to minimize the error #for profile 2
amplitude_horz[:, 2] = volume_resort[
int(volume_resort.shape[0]) - int(volume_resort.shape[0] / 3.25), :, 3
]
int(np.shape(volume)[0] / 2) + j,
int(np.shape(volume)[1] / 2) - j,
i,
]
)
volume_resort[:, :, np.argmax(diag_stack)] = volume[:, :, i]
# creating merged volumes
merge_vol = np.zeros((volume_resort.shape[0], volume_resort.shape[1]))
# creating vector for processing (1 horizontal & 1 vertical)
amplitude_horz = np.zeros(
(volume_resort.shape[1], volume_resort.shape[2])
) # 1 if it is vertical 0 if the bars are horizontal
amplitude_vert = np.zeros((volume_resort.shape[0], volume_resort.shape[2]))
y = np.linspace(
0, 0 + (volume_resort.shape[0] * dy), volume_resort.shape[0], endpoint=False
) # definition of the distance axis
x = np.linspace(
0, 0 + (volume_resort.shape[1] * dy), volume_resort.shape[1], endpoint=False
) # definition of the distance axis
ampl_resamp_y1 = np.zeros(
((volume_resort.shape[0]) * 10, int(volume_resort.shape[2] / 2))
)
ampl_resamp_y2 = np.zeros(
((volume_resort.shape[0]) * 10, int(volume_resort.shape[2] / 2))
)
ampl_resamp_x1 = np.zeros(
def merge_view_horz(volume, dx, dy):
junctions = []
# creating merged volume
merge_vol = np.zeros((volume.shape[0], volume.shape[1]))
# creating vector for processing along cols (one row)
amplitude = np.zeros(
(volume.shape[0], volume.shape[2])
) # 1 if it is vertical 0 if the bars are horizontal
y = np.linspace(
0, 0 + (volume.shape[0] * dy), volume.shape[0], endpoint=False
) # definition of the distance axis
# merging the two images together
ampl_resamp = np.zeros(((volume.shape[0]) * 10, volume.shape[2]))
for slice in tqdm(range(0, volume.shape[2])):
merge_vol = merge_vol + volume[:, :, slice]
amplitude[:, slice] = volume[:, int(volume.shape[1] / 2), slice]
ampl_resamp[:, slice] = signal.resample(
amplitude[:, slice], int(len(amplitude)) * 10
) # resampling the amplitude vector
y = np.linspace(
0, 0 + (volume_resort.shape[0] * dy), volume_resort.shape[0], endpoint=False
) # definition of the distance axis
x = np.linspace(
0, 0 + (volume_resort.shape[1] * dy), volume_resort.shape[1], endpoint=False
) # definition of the distance axis
ampl_resamp_y1 = np.zeros(
((volume_resort.shape[0]) * 10, int(volume_resort.shape[2] / 2))
)
ampl_resamp_y2 = np.zeros(
((volume_resort.shape[0]) * 10, int(volume_resort.shape[2] / 2))
)
ampl_resamp_x1 = np.zeros(
((volume_resort.shape[1]) * 10, int(volume_resort.shape[2] / 2))
)
ampl_resamp_x2 = np.zeros(
((volume_resort.shape[1]) * 10, int(volume_resort.shape[2] / 2))
)
amplitude_horz[:, 0] = volume_resort[
int(volume_resort.shape[0] / 3.25), :, 0
] # for profile 1
amplitude_horz[:, 1] = volume_resort[
int(volume_resort.shape[0] / 3.25), :, 1
] # for profile 1
amplitude_horz[:, 3] = volume_resort[
int(volume_resort.shape[0]) - int(volume_resort.shape[0] / 3.25), :, 2
] # the numbers here are reversed because we are going to slide the second graph (the overlay) to minimize the error #for profile 2
amplitude_horz[:, 2] = volume_resort[
def merge_view_vert(volume, dx, dy):
junctions = []
# creating merged volume
merge_vol = np.zeros((volume.shape[0], volume.shape[1]))
# creating vector for processing along cols (one row)
amplitude = np.zeros(
(volume.shape[1], volume.shape[2])
) # 1 if it is vertical 0 if the bars are horizontal
x = np.linspace(
0, 0 + (volume.shape[1] * dx), volume.shape[1], endpoint=False
) # definition of the distance axis
# x = np.arange(0,)#definition of the distance axis
# merging the two images together
ampl_resamp = np.zeros(((volume.shape[1]) * 10, volume.shape[2]))
# amp_peak = np.zeros((volume.shape[1]) * 10)
for item in tqdm(range(0, volume.shape[2])):
(dataset.Rows, dataset.Columns),
dtype=dataset.pixel_array.dtype,
)
ArrayDicom = np.dstack((ArrayDicom, dataset.pixel_array))
# print("slice thickness [mm]=",dataset.SliceThickness)
SID = dataset.RTImageSID
dx = 1 / (SID * (1 / dataset.ImagePlanePixelSpacing[0]) / 1000)
dy = 1 / (SID * (1 / dataset.ImagePlanePixelSpacing[1]) / 1000)
print("pixel spacing row [mm]=", dx)
print("pixel spacing col [mm]=", dy)
else:
ArrayDicom = np.dstack((ArrayDicom, dataset.pixel_array))
elif poption.startswith(("n", "no", "nope")):
dataset = pydicom.dcmread(dirname + file)
if k == 0:
ArrayDicom = np.zeros(
(dataset.Rows, dataset.Columns, 0),
dtype=dataset.pixel_array.dtype,
)
ArrayDicom = np.dstack((ArrayDicom, dataset.pixel_array))
# print("slice thickness [mm]=", dataset.SliceThickness)
SID = dataset.RTImageSID
dx = 1 / (SID * (1 / dataset.ImagePlanePixelSpacing[0]) / 1000)
dy = 1 / (SID * (1 / dataset.ImagePlanePixelSpacing[1]) / 1000)
print("pixel spacing row [mm]=", dx)
print("pixel spacing col [mm]=", dy)
else:
ArrayDicom = np.dstack((ArrayDicom, dataset.pixel_array))
print(k)
k = k + 1
xfield, yfield, rotfield = image_analyze(ArrayDicom, ioption)