Содержимое слайсов3 сохранено в 3D. Я хочу, чтобы содержимое срезов 1 сохранялось в первом измерении, срезов 2 — во вторPython

Программы на Python
Ответить Пред. темаСлед. тема
Гость
 Содержимое слайсов3 сохранено в 3D. Я хочу, чтобы содержимое срезов 1 сохранялось в первом измерении, срезов 2 — во втор

Сообщение Гость »

У меня проблемы с кодом. Содержимое clahe_slices3 сохранено в 3D. Я хочу, чтобы содержимое clahe_slices1 сохранялось в первом измерении, clahe_slices2 — во втором измерении, а clahe_slices3 — в третьем измерении. В clahe_slices для вашего сведения приведена форма каждого из них: clahe_slices.shape=(240,240,155) clahe_slices1.shape=(240,240,155) clahe_slices2.shape=(240,240,155) clahe_slices3.shape=(240,240,155) мой код

Код: Выделить всё

    nifti_img = nib.load(file_path)

# Get the image data
img_data = nifti_img.get_fdata()
clahe_slices = np.zeros_like(img_data)
clahe_slices1 = np.zeros_like(img_data)
clahe_slices2 = np.zeros_like(img_data)
clahe_slices3 = np.zeros_like(img_data)

#I have filtered slides, but when editing the dimension must be specified like     #this, and when I specify the dimension, it filters the other dimensions, but     #it does not verify that the slide content in the other dimensions is empty,       #and thus there are problems in the result.
#Because of this, I thought of applying the filter and specifying a dimension     #each time, and in the end I collect the results of each dimension to obtain       #correct results. Here, when I specify that, it does not save the result of       #clahe_slices1 and clahe_slices2, but only the result of the last episode in        #all dimensions. I'm still new to nifti anf numpy.
#Please give me a solution to this, thank you
#The code is very long and only included the important elements in
#the problem
for i in range(img_data.shape[0]):
# Assuming the slice dimension is the first dimension
clahe_slices[i, :, :] = clahe_slices1[i, :, :]
for i in range(img_data.shape[2]):
# Assuming the slice dimension is the third dimension
clahe_slices[:, :, i] = clahe_slices3[:, :, i]
for i in range(img_data.shape[1]):
# Assuming the slice dimension is the second dimension
clahe_slices[:, i, :] = clahe_slices2[:, i, :]

# Example usage:
return clahe_slices


У меня проблемы с кодом. Содержимое clahe_slices3 сохраняется во всех измерениях в clahe_slices. Я хочу, чтобы содержимое clahe_slices1 сохранялось в первом измерении, clahe_slices2 — во втором измерении, а clahe_slices3 — в третьем измерении. В clahe_slices

Подробнее здесь: https://stackoverflow.com/questions/781 ... -in-the-fi
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «Python»