# \#python

**URL:** https://discourse.itk.org/tag/python/4.md?match_all_tags=true&page=3&tags%5B%5D=python

[Latest](https://discourse.itk.org/latest.md) · [Categories](https://discourse.itk.org/categories.md) · [Tags](https://discourse.itk.org/tags.md)

**Page:** 4

---

## [How to preprocess diffusion MRI?](https://discourse.itk.org/t/how-to-preprocess-diffusion-mri/6581)

<div class="topic-metadata">

**Author:** [@Sunita\_Patel](https://discourse.itk.org/u/Sunita_Patel)\
**Replies:** 2\
**Last updated:** [April 18, 2024, 10:19am UTC](https://discourse.itk.org/t/how-to-preprocess-diffusion-mri/6581 "2024-04-18T10:19:19Z")

</div>

Dear SITK-users How to preprocess diffusion MRI DICOM images? So far we have been using publicly available processed DWI nifti file and the given .bvec and .bval files. Now, we would like to do preprocessing from DICOM …

---

## [\[Question\] Python not found during compilation](https://discourse.itk.org/t/question-python-not-found-during-compilation/6580)

<div class="topic-metadata">

**Author:** [@Suzaku](https://discourse.itk.org/u/Suzaku)\
**Replies:** 1\
**Last updated:** [April 17, 2024, 1:03pm UTC](https://discourse.itk.org/t/question-python-not-found-during-compilation/6580 "2024-04-17T13:03:15Z")

</div>

Hi, I’m trying to compile SimpleITK with SimpleElastix in a ubuntu 20.04.6 LTS system. I’ve used the following command as suggested in the documentation: git clone GitHub - SimpleITK/SimpleITK: SimpleITK: a layer built o…

---

## [Landmark Image Registration of Images with different Resolutions](https://discourse.itk.org/t/landmark-image-registration-of-images-with-different-resolutions/6573)

<div class="topic-metadata">

**Author:** [@luviku](https://discourse.itk.org/u/luviku)\
**Replies:** 2\
**Last updated:** [April 16, 2024, 7:16am UTC](https://discourse.itk.org/t/landmark-image-registration-of-images-with-different-resolutions/6573 "2024-04-16T07:16:24Z")

</div>

Hello everyone, I am a beginner so please forgive me if this is a basic question. I am working on registering Spectralis SLO images with OCT-A images. I am using landmarks to identify points on vessels, which correlate …

---

## [Copy headers / metadata between segmentations of different resolutions](https://discourse.itk.org/t/copy-headers-metadata-between-segmentations-of-different-resolutions/6558)

<div class="topic-metadata">

**Author:** [@Cristobal\_Rodero](https://discourse.itk.org/u/Cristobal_Rodero)\
**Replies:** 1\
**Last updated:** [April 9, 2024, 7:28pm UTC](https://discourse.itk.org/t/copy-headers-metadata-between-segmentations-of-different-resolutions/6558 "2024-04-09T19:28:37Z")

</div>

I have a coarse segmentation that I smooth, and the smoothing techniques overwrites the header. I want to retrieve the original one but I have had no success so far. The headers are \_, coarse\_header = nrrd.re…

---

## [ITK Image Direction vs DICOM Image Orientation (Patient)](https://discourse.itk.org/t/itk-image-direction-vs-dicom-image-orientation-patient/6364)

<div class="topic-metadata">

**Author:** [@aditya](https://discourse.itk.org/u/aditya)\
**Replies:** 3\
**Last updated:** [April 9, 2024, 7:47am UTC](https://discourse.itk.org/t/itk-image-direction-vs-dicom-image-orientation-patient/6364 "2024-04-09T07:47:25Z")

</div>

I am working with a directory containing sagittal DICOM images. Here is how I obtain Image Orientation (DICOM tag 0020,0037) using pydicom. from pydicom import dcmread import os dcm\_dir = r"path/to/dicom/dir/sagittal\_a…

---

## [how to build ITK 5.3.0 with Python bindings in Linux?](https://discourse.itk.org/t/how-to-build-itk-5-3-0-with-python-bindings-in-linux/6544)

<div class="topic-metadata">

**Author:** [@edgar](https://discourse.itk.org/u/edgar)\
**Replies:** 9\
**Last updated:** [April 8, 2024, 5:51pm UTC](https://discourse.itk.org/t/how-to-build-itk-5-3-0-with-python-bindings-in-linux/6544 "2024-04-08T17:51:18Z")

</div>

Hello. I would like to know if someone can help me to build ITK 5.3.0 with Python bindings in Linux. The idea is to have a reproducible build, which implies that downloading the binary packages is not an option. Thank yo…

---

## [How to do registration and resampling of T1W 3D image and the tumor mask with MNI152 template?](https://discourse.itk.org/t/how-to-do-registration-and-resampling-of-t1w-3d-image-and-the-tumor-mask-with-mni152-template/6549)

<div class="topic-metadata">

**Author:** [@Sunita\_Patel](https://discourse.itk.org/u/Sunita_Patel)\
**Replies:** 7\
**Last updated:** [April 5, 2024, 6:34pm UTC](https://discourse.itk.org/t/how-to-do-registration-and-resampling-of-t1w-3d-image-and-the-tumor-mask-with-mni152-template/6549 "2024-04-05T18:34:34Z")

</div>

Dear forum members, We have T1W 3D image and its tumor mask of shape 240 x 240 x 155. Now we want to register both image and mask to MNI152 template. MNI152 (mni\_icbm152\_t1\_nlin\_asym\_09a) shape is 197 x 233 x 189. We ar…

---

## [How do you access the "Modality" metadata from the MHA header?](https://discourse.itk.org/t/how-do-you-access-the-modality-metadata-from-the-mha-header/6547)

<div class="topic-metadata">

**Author:** [@nicoco](https://discourse.itk.org/u/nicoco)\
**Replies:** 1\
**Last updated:** [March 28, 2024, 6:46pm UTC](https://discourse.itk.org/t/how-do-you-access-the-modality-metadata-from-the-mha-header/6547 "2024-03-28T18:46:35Z")

</div>

Some MHAs contain a “Modality” tag, which seems to be treated differently than other keys. How do we access it? Some sort of MWE: \> cat /tmp/test.mha ObjectType = Image NDims = 3 BinaryData = True BinaryDataByteOrderMS…

---

## [Differences after applying forward & inverse transform](https://discourse.itk.org/t/differences-after-applying-forward-inverse-transform/6536)

<div class="topic-metadata">

**Author:** [@Mckay42](https://discourse.itk.org/u/Mckay42)\
**Replies:** 2\
**Last updated:** [March 21, 2024, 5:54am UTC](https://discourse.itk.org/t/differences-after-applying-forward-inverse-transform/6536 "2024-03-21T05:54:18Z")

</div>

Hi all, I started using sitk a while ago and hope to use it for registration tasks in my project. While playing around with it, I tried to apply a simple Euler3D transform to my image and revert it with the the inverse…

---

## [Setting an Initial Transform for Elastix](https://discourse.itk.org/t/setting-an-initial-transform-for-elastix/6532)

<div class="topic-metadata">

**Author:** [@lschuring](https://discourse.itk.org/u/lschuring)\
**Replies:** 1\
**Last updated:** [March 19, 2024, 8:33pm UTC](https://discourse.itk.org/t/setting-an-initial-transform-for-elastix/6532 "2024-03-19T20:33:51Z")

</div>

Hi ITK community! I am setting up a pipeline in python to register MRI image stacks which tend to have poor initial alignment. I would like to provide an elastix image filter (sitk.ElastixImageFilter()) an initial trans…

---

## [Convert a displacement filed nifty image to SITK transform type](https://discourse.itk.org/t/convert-a-displacement-filed-nifty-image-to-sitk-transform-type/4210)

<div class="topic-metadata">

**Author:** [@VHK](https://discourse.itk.org/u/VHK)\
**Replies:** 4\
**Last updated:** [March 19, 2024, 12:53pm UTC](https://discourse.itk.org/t/convert-a-displacement-filed-nifty-image-to-sitk-transform-type/4210 "2024-03-19T12:53:40Z")

</div>

Hello everyone, I have a displacement field Nifti format (field.nii.gz). How can I convert it to sitk.transform type (field.tfm) so that I can use it as transformation in SITK? I really appreciate any help you can prov…

---

## [Plot TRE per iteration for 2D registration](https://discourse.itk.org/t/plot-tre-per-iteration-for-2d-registration/6505)

<div class="topic-metadata">

**Author:** [@Vojtech\_Benda](https://discourse.itk.org/u/Vojtech_Benda)\
**Replies:** 4\
**Last updated:** [March 15, 2024, 12:14pm UTC](https://discourse.itk.org/t/plot-tre-per-iteration-for-2d-registration/6505 "2024-03-15T12:14:35Z")

</div>

Hello, I’m trying to plot target registration error (TRE) values at each iteration as shown in this notebook in the Registration cell. The input images are 3D and 2D, where the 3D image is sliced into 2D. They are transf…

---

## [ADMM Reconstruction](https://discourse.itk.org/t/admm-reconstruction/6490)

<div class="topic-metadata">

**Author:** [@zhangm](https://discourse.itk.org/u/zhangm)\
**Replies:** 13\
**Last updated:** [March 8, 2024, 12:46am UTC](https://discourse.itk.org/t/admm-reconstruction/6490 "2024-03-08T00:46:01Z")

</div>

I successfully ran the FirstCudaReconstruction.py file on my project. But sometimes the scanning angle may only be 90 °, and the reconstruction effect using FDK is not good. I checked the rtk and found that ADMM reconstr…

---

## [Transfer from CPUImage to GPUImage](https://discourse.itk.org/t/transfer-from-cpuimage-to-gpuimage/6492)

<div class="topic-metadata">

**Author:** [@zhangm](https://discourse.itk.org/u/zhangm)\
**Replies:** 3\
**Last updated:** [March 5, 2024, 2:12pm UTC](https://discourse.itk.org/t/transfer-from-cpuimage-to-gpuimage/6492 "2024-03-05T14:12:54Z")

</div>

I need transfer from CPUImage to GPUImage in python. And I find this discourse by use itk.cuda\_image\_to\_image\_filter() to complete the conversion. But the error prompt seems that the fuction only support input type as G…

---

## [How to get image mask in simpleitk?](https://discourse.itk.org/t/how-to-get-image-mask-in-simpleitk/6470)

<div class="topic-metadata">

**Author:** [@dstansby](https://discourse.itk.org/u/dstansby)\
**Replies:** 4\
**Last updated:** [February 29, 2024, 9:29pm UTC](https://discourse.itk.org/t/how-to-get-image-mask-in-simpleitk/6470 "2024-02-29T21:29:59Z")

</div>

I’m trying to set and get a mask on an image using simpleitk in Python. I’m setting the mask like this: image: sitk.Image mask: npt.NDArray masked\_image = sitk.Mask(image, sitk.GetImageFromArray(mask)) I can’t work out…

---

## [Fusion between segmentation and reference image](https://discourse.itk.org/t/fusion-between-segmentation-and-reference-image/6469)

<div class="topic-metadata">

**Author:** [@Nuno\_Loucao1](https://discourse.itk.org/u/Nuno_Loucao1)\
**Replies:** 1\
**Last updated:** [February 26, 2024, 4:09pm UTC](https://discourse.itk.org/t/fusion-between-segmentation-and-reference-image/6469 "2024-02-26T16:09:19Z")

</div>

Hi! I’m performing an analysis on a 4D breast MRI scan. I’m trying to fuse the segmentation results on a reference image dataset (3D), but without results. So i have the lesion segmented, then i multiply it by, p.ex.,…

---

## [CMake Error when building ITKMontage wheel for aarch64](https://discourse.itk.org/t/cmake-error-when-building-itkmontage-wheel-for-aarch64/6452)

<div class="topic-metadata">

**Author:** [@John\_Bergelin](https://discourse.itk.org/u/John_Bergelin)\
**Replies:** 3\
**Last updated:** [February 23, 2024, 1:38pm UTC](https://discourse.itk.org/t/cmake-error-when-building-itkmontage-wheel-for-aarch64/6452 "2024-02-23T13:38:35Z")

</div>

Hi, I’m trying to compile and build an ITKMontage python3.9 wheel for aarch64 on a raspberry pi 4 using ITKPythonPackage as described here Prerequisites — ITKPythonPackage documentation I’ve checked out the release bra…

---

## [Set Image Direction from numpy array](https://discourse.itk.org/t/set-image-direction-from-numpy-array/844)

<div class="topic-metadata">

**Author:** [@nicoco](https://discourse.itk.org/u/nicoco)\
**Replies:** 25\
**Last updated:** [February 22, 2024, 1:18am UTC](https://discourse.itk.org/t/set-image-direction-from-numpy-array/844 "2024-02-22T01:18:35Z")

</div>

Hello, I’m struggling to use a numpy array in order to set the direction of an ITK Image using python bindings. My attempts: In \[8\]: image = itk.Image.New() In \[9\]: np\_dir = np.eye(2) In \[10\]: image.SetDirection(itk…

---

## [Measuring Aorta Diameter from centerline using ITK](https://discourse.itk.org/t/measuring-aorta-diameter-from-centerline-using-itk/6447)

<div class="topic-metadata">

**Author:** [@idinsmore1](https://discourse.itk.org/u/idinsmore1)\
**Replies:** 7\
**Last updated:** [February 21, 2024, 1:16am UTC](https://discourse.itk.org/t/measuring-aorta-diameter-from-centerline-using-itk/6447 "2024-02-21T01:16:44Z")

</div>

Hello! I’ve been trying to implement a python method for automatically measuring the aortic diameter from CT segmentations. I was previously trying to do this all in numpy/scipy, but I think I need the efficiency and th…

---

## [How to use the GetScalesOutput() method in MultiscaleHessianBasedMeasureImageFilter](https://discourse.itk.org/t/how-to-use-the-getscalesoutput-method-in-multiscalehessianbasedmeasureimagefilter/6433)

<div class="topic-metadata">

**Author:** [@Tomo](https://discourse.itk.org/u/Tomo)\
**Replies:** 4\
**Last updated:** [February 13, 2024, 3:40am UTC](https://discourse.itk.org/t/how-to-use-the-getscalesoutput-method-in-multiscalehessianbasedmeasureimagefilter/6433 "2024-02-13T03:40:34Z")

</div>

Hello, I am interested in applying a vesselness filter process to MRA images, referencing “Antiga, L. (2007). Generalizing vesselness with respect to dimensionality and shape. The Insight Journal.” I have written a scri…

---

## [\[itk-python\] Create an image with GPU](https://discourse.itk.org/t/itk-python-create-an-image-with-gpu/6414)

<div class="topic-metadata">

**Author:** [@zhangm](https://discourse.itk.org/u/zhangm)\
**Replies:** 13\
**Last updated:** [January 29, 2024, 10:04am UTC](https://discourse.itk.org/t/itk-python-create-an-image-with-gpu/6414 "2024-01-29T10:04:53Z")

</div>

I used pip to install itk5.4.0, and running some demo about RTK. There was normal when I running FirstReconstruction.py, but there was an error when running FirstCudaReconstruction.py. Both using itk.GPUImage and itk.RTK…

---

## [How do you compose transforms after registration to perform resampling?](https://discourse.itk.org/t/how-do-you-compose-transforms-after-registration-to-perform-resampling/6401)

<div class="topic-metadata">

**Author:** [@sdiebolt](https://discourse.itk.org/u/sdiebolt)\
**Replies:** 6\
**Last updated:** [January 23, 2024, 4:10pm UTC](https://discourse.itk.org/t/how-do-you-compose-transforms-after-registration-to-perform-resampling/6401 "2024-01-23T16:10:11Z")

</div>

I have a question that has already been asked at least twice (here and here) but got no explicit answer. Like their original authors, I’m struggling to understand how to compose the fixed initial, moving initial, and opt…

---

## [ITK 5.4 Release Candidate 1 available for testing](https://discourse.itk.org/t/itk-5-4-release-candidate-1-available-for-testing/6107)

<div class="topic-metadata">

**Author:** [@matt.mccormick](https://discourse.itk.org/u/matt.mccormick)\
**Replies:** 2\
**Last updated:** [January 22, 2024, 9:00pm UTC](https://discourse.itk.org/t/itk-5-4-release-candidate-1-available-for-testing/6107 "2024-01-22T21:00:04Z")

</div>

ITK 5.4 Release Candidate 1: C++17 We are happy to announce the Insight Toolkit (ITK) 5.4 Release Candidate 1 is available for testing! :tada: ITK is an open-source, cross-platform toolkit for N-dimensional scientific im…

---

## [SmoothingRecursiveGaussian vs DiscreteGaussian](https://discourse.itk.org/t/smoothingrecursivegaussian-vs-discretegaussian/6370)

<div class="topic-metadata">

**Author:** [@reox](https://discourse.itk.org/u/reox)\
**Replies:** 4\
**Last updated:** [December 21, 2023, 3:24pm UTC](https://discourse.itk.org/t/smoothingrecursivegaussian-vs-discretegaussian/6370 "2023-12-21T15:24:50Z")

</div>

Here is a small example using both SmoothingRecursiveGaussian and DiscreteGaussian to smooth an image. Both filter should use the same σ of 0.8 - as far as I understood the documentation, the Recursive filter has the sta…

---

## [What are the valid input parameters of the different optimization algorithms available in SimpleITK?](https://discourse.itk.org/t/what-are-the-valid-input-parameters-of-the-different-optimization-algorithms-available-in-simpleitk/6314)

<div class="topic-metadata">

**Author:** [@debapriya](https://discourse.itk.org/u/debapriya)\
**Replies:** 8\
**Last updated:** [December 18, 2023, 1:50pm UTC](https://discourse.itk.org/t/what-are-the-valid-input-parameters-of-the-different-optimization-algorithms-available-in-simpleitk/6314 "2023-12-18T13:50:54Z")

</div>

Hello, I want to compare the performance of different optimization algorithms while registering two images. For this purpose, I want to know what are the valid input parameters (step size, function tolerance, number of …

---

## [Torch import time](https://discourse.itk.org/t/torch-import-time/6354)

<div class="topic-metadata">

**Author:** [@tbaudier](https://discourse.itk.org/u/tbaudier)\
**Replies:** 2\
**Last updated:** [December 14, 2023, 5:07pm UTC](https://discourse.itk.org/t/torch-import-time/6354 "2023-12-14T17:07:24Z")

</div>

Hi, In a new virtual environment, I installed itk with pypi and I tested the import time: ITK is fast to import. But now, I installed torch with pypi: The import time is huge now, due to torch. I do not need tor…

---

## [deformable PointSet to PointSet registration with python](https://discourse.itk.org/t/deformable-pointset-to-pointset-registration-with-python/6351)

<div class="topic-metadata">

**Author:** [@HnHd](https://discourse.itk.org/u/HnHd)\
**Replies:** 2\
**Last updated:** [December 11, 2023, 7:38pm UTC](https://discourse.itk.org/t/deformable-pointset-to-pointset-registration-with-python/6351 "2023-12-11T19:38:39Z")

</div>

Hello all, I am trying to implement a deformable registration for two pointsets in python-itk. Being a newbie I started with the itk.PointSetToPointSetRegistrationMethod, but got stuck when trying to set the metric for…

---

## [Checking simpleitk.Image Equality](https://discourse.itk.org/t/checking-simpleitk-image-equality/6323)

<div class="topic-metadata">

**Author:** [@Franciska](https://discourse.itk.org/u/Franciska)\
**Replies:** 5\
**Last updated:** [November 29, 2023, 3:37pm UTC](https://discourse.itk.org/t/checking-simpleitk-image-equality/6323 "2023-11-29T15:37:19Z")

</div>

Hi! I have two methods to the same task. I’d like to check, whether the result of the two methods gives equal outcomes. The files are nifti Images. I can check if their numpy part is the same easily: output1=sitk.Read…

---

## [Resolving Image Cropping Issue in NIFTI Image Resampling](https://discourse.itk.org/t/resolving-image-cropping-issue-in-nifti-image-resampling/6313)

<div class="topic-metadata">

**Author:** [@hjy0404](https://discourse.itk.org/u/hjy0404)\
**Replies:** 3\
**Last updated:** [November 21, 2023, 3:05am UTC](https://discourse.itk.org/t/resolving-image-cropping-issue-in-nifti-image-resampling/6313 "2023-11-21T03:05:56Z")

</div>

I am trying to resample a NIFTI image from a resolution of 512,512,661 to 512,512,147 using SimpleITK. Below is the code I’ve used: def resample\_to\_original\_size(isotropic\_img, ref\_img): original\_spacing = ref\_img.…

---

## [Use of TransformRigidityPenalty Fails](https://discourse.itk.org/t/use-of-transformrigiditypenalty-fails/6273)

<div class="topic-metadata">

**Author:** [@calici](https://discourse.itk.org/u/calici)\
**Replies:** 2\
**Last updated:** [November 17, 2023, 1:51pm UTC](https://discourse.itk.org/t/use-of-transformrigiditypenalty-fails/6273 "2023-11-17T13:51:34Z")

</div>

Hi! I am using deformable intensity-based algorithm to register pretreatment and posttreatment CT pairs. I want a specific region defined by a segmentation not to be deformed much during nonlinear registration. For tha…

[Previous page](https://discourse.itk.org/tag/python/4.md?match_all_tags=true&page=2&tags%5B%5D=python)

[Next page](https://discourse.itk.org/tag/python/4.md?match_all_tags=true&page=4&tags%5B%5D=python)
