# Resample volume with unregular spacing

**URL:** <https://discourse.slicer.org/t/resample-volume-with-unregular-spacing/21559>\
**Category:** Support\
**Tags:** resample\
**Created:** [January 21, 2022, 1:58pm UTC](https://discourse.slicer.org/t/resample-volume-with-unregular-spacing/21559 "2022-01-21T13:58:03Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![LaurennLam](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/laurennlam/32/16833_2.png) [@LaurennLam](https://discourse.slicer.org/u/LaurennLam)\
**Post date:** [January 21, 2022, 1:58pm UTC](https://discourse.slicer.org/t/resample-volume-with-unregular-spacing/21559/1 "2022-01-21T13:58:03Z")

</div>

Hi everyone,

I’m trying to resampled a volume with an unregular spacing along Z axis.  
I followed this [post](https://C:%5CKitware%5CProjects%5CEDAP%5CCMake%5Cscript%5CdefinePaths.bat) but I encountered issue when resampling.  
Here are the steps I followed:

- Loading dicom volume as `dicomVolume`
- It also creates an acquisition transform `transform` (vtkMRMLGridTransform)
- I used Resample Scalar Volume by specifying output spacing (I’ll use the output as an input for the other Resample filter) with `dicomVolume` as an input and create a new volume `tempResampledVolume`
- I launch the Resample Image (BRAINS) by setting:  
– ImageToWrap: `dicomVolume`  
– Reference image: `tempResampledVolume`  
– Transform file: `transform`  
The resampling fails with this error :

```auto
[FAILED]
Error while reading the the file C:/blablabla/Slicer/BJAIA_vtkMRMLGridTransformNodeB.h5

itk::ExceptionObject (000000D6A50FDA00)
Location: "unknown" 
File: D:\D\S\Slicer-1-build\ITK\Modules\IO\TransformBase\src\itkTransformIOBase.cxx
Line: 62
Description: itk::ERROR: itk::ERROR: HDF5TransformIOTemplate(0000024174726940): Could not create an instance of "InverseDisplacementFieldTransform_double_3_3"
The usual cause of this error is not registering the transform with TransformFactory
Currently registered Transforms: 
	"AffineTransform_double_2_2"
	"AffineTransform_double_3_3"
	"AffineTransform_double_4_4"
	"AffineTransform_float_2_2"
	"AffineTransform_float_3_3"
	"AffineTransform_float_4_4"
	"AzimuthElevationToCartesianTransform_double_3_3"
	"AzimuthElevationToCartesianTransform_float_3_3"
       .....

```

My understanding is that there are some issue with the transform but I don’t understand what exactly.  
Thanks for your help.

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [January 23, 2022, 8:41pm UTC](https://discourse.slicer.org/t/resample-volume-with-unregular-spacing/21559/2 "2022-01-23T20:41:29Z")

</div>

> [@LaurennLam](#):
>
> I followed this [post](https://C:%5CKitware%5CProjects%5CEDAP%5CCMake%5Cscript%5CdefinePaths.bat) but I encountered issue when resampling.

Can you re-send the post you linked to? It’s not coming through.

As a workaround you can use the “harden transform” option in the transforms module.

---

<div class="post-metadata">

**Author:** ![LaurennLam](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/laurennlam/32/16833_2.png) [@LaurennLam](https://discourse.slicer.org/u/LaurennLam)\
**Post date:** [January 24, 2022, 11:51am UTC](https://discourse.slicer.org/t/resample-volume-with-unregular-spacing/21559/3 "2022-01-24T11:51:34Z")

</div>

Sorry for the fail.  
Here is the [link](https://discourse.itk.org/t/account-for-non-uniform-spacing/2797/4)

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [January 24, 2022, 1:28pm UTC](https://discourse.slicer.org/t/resample-volume-with-unregular-spacing/21559/4 "2022-01-24T13:28:07Z")

</div>

> [@LaurennLam](#):
>
> Here is the [link](https://discourse.itk.org/t/account-for-non-uniform-spacing/2797/4)

Thanks! Yes, I figured it was that one or something similar.

For now I think hardening the volume through the transforms or data module is best. Passing the grid transform to the brains resampler really should work and I’m not sure why it doesn’t.

---

<div class="post-metadata">

**Author:** ![LaurennLam](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/laurennlam/32/16833_2.png) [@LaurennLam](https://discourse.slicer.org/u/LaurennLam)\
**Post date:** [January 24, 2022, 2:16pm UTC](https://discourse.slicer.org/t/resample-volume-with-unregular-spacing/21559/5 "2022-01-24T14:16:50Z")

</div>

Thanks for your fast answer. Indeed, I was able to apply the harden transform. I didn’t remember how to do this. It seems to work well. Thanks !!
