简体   繁体   English

MemoryError: 无法为 DIPY 图像配准中具有形状 (344, 344, 127) 和数据类型 float64 的数组分配 115. MiB

[英]MemoryError: Unable to allocate 115. MiB for an array with shape (344, 344, 127) and data type float64 in DIPY image registration

I'm trying to do image registration using DIPY (Affine registration in 3d) I tried to run the following code (Actually I tried to reproduce the example code with a different nifti file)我正在尝试使用 DIPY(3d 中的仿射注册)进行图像注册我尝试运行以下代码(实际上我尝试使用不同的 nifti 文件重现示例代码

from os.path import join as pjoin
import numpy as np
from dipy.viz import regtools
from dipy.data import fetch_mni_template, read_mni_template
from dipy.data.fetcher import fetch_syn_data, read_syn_data
from dipy.io.image import load_nifti
from dipy.align.imaffine import (transform_centers_of_mass,
                                 AffineMap,
                                 MutualInformationMetric,
                                 AffineRegistration)
from dipy.align.transforms import (TranslationTransform3D,
                                   RigidTransform3D,
                                   AffineTransform3D)

files, folder = fetch_mni_template()
static_data, static_affine = load_nifti(pjoin(folder, 'mni_icbm152_t1_tal_nlin_asym_09a.nii'))
static = np.squeeze(static_data)
static_grid2world = static_affine

files, folder = fetch_syn_data()
moving_data, moving_affine = load_nifti(pjoin(folder, '2018.nii'))
moving = moving_data
moving_grid2world = moving_affine

identity = np.eye(4)
affine_map = AffineMap(identity,
                       static.shape, static_grid2world,
                       moving.shape, moving_grid2world)
print(static.shape)


resampled = affine_map.transform(moving)


regtools.overlay_slices(static, resampled, None, 0,
                        "Static", "Moving", "resampled_0.png")
regtools.overlay_slices(static, resampled, None, 1,
                        "Static", "Moving", "resampled_1.png")
regtools.overlay_slices(static, resampled, None, 2,
                        "Static", "Moving", "resampled_2.png")

c_of_mass = transform_centers_of_mass(static, static_grid2world,
                                      moving, moving_grid2world)

transformed = c_of_mass.transform(moving)
regtools.overlay_slices(static, transformed, None, 0,
                        "Static", "Transformed", "transformed_com_0.png")
regtools.overlay_slices(static, transformed, None, 1,
                        "Static", "Transformed", "transformed_com_1.png")
regtools.overlay_slices(static, transformed, None, 2,
                        "Static", "Transformed", "transformed_com_2.png")

nbins = 32
sampling_prop = None
metric = MutualInformationMetric(nbins, sampling_prop)

level_iters = [10000, 1000, 100]

sigmas = [3.0, 1.0, 0.0]

factors = [4, 2, 1]

affreg = AffineRegistration(metric=metric,
                            level_iters=level_iters,
                            sigmas=sigmas,
                            factors=factors)

transform = TranslationTransform3D()
params0 = None
starting_affine = c_of_mass.affine

translation = affreg.optimize(static, moving, transform, params0,
                              static_grid2world, moving_grid2world,
                              starting_affine=starting_affine)

but im getting the following error但我收到以下错误

MemoryError: Unable to allocate 115. MiB for an array with shape (344, 344, 127) and data type float64内存错误:无法为形状为 (344, 344, 127) 且数据类型为 float64 的数组分配 115. MiB

I couldn't find a solution for this.我找不到解决方案。

I solved this issue by moving from 32 bit version of python to 64 bit version我通过从 32 位版本的 python 移动到 64 位版本解决了这个问题

Thanks, Mani谢谢,玛尼

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 MemoryError: Unable to allocate 115. GiB for an array with shape (1122, 1122, 12288) and data type float64 - MemoryError: Unable to allocate 115. GiB for an array with shape (1122, 1122, 12288) and data type float64 MemoryError: Unable to allocate 797. MiB for an array with shape (51, 51, 40169) and data type float64 - MemoryError: Unable to allocate 797. MiB for an array with shape (51, 51, 40169) and data type float64 无法为形状为 (1080, 1920, 3) 且数据类型为 float64 的数组分配 47.5 MiB - Unable to allocate 47.5 MiB for an array with shape (1080, 1920, 3) and data type float64 无法为形状为 (3, 1267618) 且数据类型为 float64 的数组分配 29.0 MiB - Unable to allocate 29.0 MiB for an array with shape (3, 1267618) and data type float64 MemoryError: 无法分配形状 (118, 840983) 和数据类型 float64 的数组 - MemoryError: Unable to allocate array with shape (118, 840983) and data type float64 MemoryError: 无法分配形状为 (200, 20, 244, 244, 3) 和数据类型为 float64 的数组 - MemoryError: Unable to allocate array with shape (200, 20, 244, 244, 3) and data type float64 MemoryError:无法为形状为 (323313, 3435) 且数据类型为 float64 的数组分配 8.27 GiB - MemoryError: Unable to allocate 8.27 GiB for an array with shape (323313, 3435) and data type float64 MemoryError: Unable to allocate 617. GiB for an array with shape (82754714206,) and data type float64 On Windows and using Python - MemoryError: Unable to allocate 617. GiB for an array with shape (82754714206,) and data type float64 On Windows and using Python MemoryError: Unable to allocate 137. MiB for an array with shape (3000, 4000, 3) and data type float32 - MemoryError: Unable to allocate 137. MiB for an array with shape (3000, 4000, 3) and data type float32 如何清理 memory 或使用 SageMaker 来避免 MemoryError: Unable to allocate for an array with shape (25000, 2000) and data type float64 - How can I clean memory or use SageMaker instead to avoid MemoryError: Unable to allocate for an array with shape (25000, 2000) and data type float64
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM