# Correct 3D drift implementation in KNIME

**URL:** <https://forum.knime.com/t/correct-3d-drift-implementation-in-knime/25187>\
**Category:** KNIME Extensions\
**Tags:** image-processing\
**Created:** [July 11, 2020, 11:10pm UTC](https://forum.knime.com/t/correct-3d-drift-implementation-in-knime/25187 "2020-07-11T23:10:33Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![aseeber](https://forum-cdn.knime.com/user_avatar/forum.knime.com/aseeber/32/13546_2.png) [@aseeber](https://forum.knime.com/u/aseeber)\
**Post date:** [July 11, 2020, 11:10pm UTC](https://forum.knime.com/t/correct-3d-drift-implementation-in-knime/25187/1 "2020-07-11T23:10:33Z")

</div>

I noticed that a lot of my workflows lack a 3D drift correction node like the imagej plugins “[Correct 3D drift](https://github.com/tischi/fiji-correct-3d-drift)” or “[stackreg](http://bigwww.epfl.ch/thevenaz/stackreg/)” / “[multistackreg](http://bradbusse.net/sciencedownloads.html)”. Currently, I always do this step outside of KNIME which slows everything down considerably (mostly because the image writer node is slow). I was wondering if anyone had tried to implement registration/drift correction functions directly in KNIME yet?

I spent some time attempting to do this myself. The easiest thing looked like taking “Correct 3D drift” script, annotating it for KNIME and using Maven to package the jar.

I ran into a number of problems though, likely because I am a horrendously inexperienced with ImageJ2 macros. Most of the examples I’ve found online (thanks @imagejan, @stelfrich) use Java. “Correct 3D drift” is python, so how do I correctly annotate this for KNIME? Do I need to rewrite everything in Java using command classes? Am I better off / is is possible to run this as a pure python script off of a python node?

Thanks for any help or suggestions!

If anyone would like to take a crack at this themselves, here is a [link](https://drive.google.com/file/d/1UIedoNv1_I1IEXvpwm4m25cBqr7TZkQg/view?usp=sharing) to 2 a channel image of a cell that moves a little over time.

---

<div class="post-metadata">

**Author:** ![stelfrich](https://forum-cdn.knime.com/user_avatar/forum.knime.com/stelfrich/32/205_2.png) [@stelfrich](https://forum.knime.com/u/stelfrich)\
**Post date:** [July 13, 2020, 11:36am UTC](https://forum.knime.com/t/correct-3d-drift-implementation-in-knime/25187/2 "2020-07-13T11:36:48Z")

</div>

Hi Andrew!

> [@aseeber](#):
>
> I was wondering if anyone had tried to implement registration/drift correction functions directly in KNIME yet?

There’s the [Align image](https://kni.me/n/kSFnA7jiSRZZcEbP) node that does registration of images along a dimension (in contrast to what its name suggests). Works quite well for the example data that you have provided!

> [@aseeber](#):
>
> I spent some time attempting to do this myself. The easiest thing looked like taking “Correct 3D drift” script, annotating it for KNIME and using Maven to package the jar.

Unfortunately, that won’t work in KNIME. @Christian_Tischer, however, has worked on a native Java Image Registration Suite some time ago. Progress seems to have stalled a little, though. If you are curious, discussions have happened in this thread:

> **[Image Registration Suite](https://forum.image.sc/t/image-registration-suite/7164/16)**
>
> Yea, that nasty behaviour is due to overflows. Its fixed by this ClampingNLinearInterpolator, but it lives in the bigdataviewer-core at the moment and hasn’t made it into imglib2-core yet. (Edit: since Fiji has the bigdataviewer built in, you...

Best,  
Stefan

---

<div class="post-metadata">

**Author:** ![aseeber](https://forum-cdn.knime.com/user_avatar/forum.knime.com/aseeber/32/13546_2.png) [@aseeber](https://forum.knime.com/u/aseeber)\
**Post date:** [July 13, 2020, 12:40pm UTC](https://forum.knime.com/t/correct-3d-drift-implementation-in-knime/25187/3 "2020-07-13T12:40:08Z")

</div>

Ah yes, I didn’t realize the “align” node could be used like that! This works great for my use case. I’ll take a look at [Image Registration Suite](https://forum.image.sc/t/image-registration-suite/7164/16), thanks for the link.

---

<div class="post-metadata">

**Author:** ![aseeber](https://forum-cdn.knime.com/user_avatar/forum.knime.com/aseeber/32/13546_2.png) [@aseeber](https://forum.knime.com/u/aseeber)\
**Post date:** [July 13, 2020, 5:11pm UTC](https://forum.knime.com/t/correct-3d-drift-implementation-in-knime/25187/4 "2020-07-13T17:11:47Z")

</div>

In case someone needs it in the future, I made a quick example workflow showing how the align node can work in some cases ([link](https://drive.google.com/file/d/1r_pCgCXcJctb2k6E6xe5c1iy13htkr5E/view?usp=sharing)). This workflow takes a 2 channel time series. It aligns channel 2 relative to channel 1. Then it aligns both channels through time.

 ![Using the align node](https://forum-cdn.knime.com/uploads/default/original/3X/9/0/9015a01573664c71d471619bec2b7d7039876b79.png)

---

<div class="post-metadata">

**Author:** ![imagejan](https://forum-cdn.knime.com/user_avatar/forum.knime.com/imagejan/32/47_2.png) [@imagejan](https://forum.knime.com/u/imagejan)\
**Post date:** [July 13, 2020, 8:04pm UTC](https://forum.knime.com/t/correct-3d-drift-implementation-in-knime/25187/5 "2020-07-13T20:04:00Z")

</div>

> [@aseeber](#):
>
> I made a quick example workflow showing how the align node can work in some cases ([link](https://drive.google.com/file/d/1r_pCgCXcJctb2k6E6xe5c1iy13htkr5E/view?usp=sharing)).

Thanks, Andrew, for sharing the example! The link requires me to request access, is that intended? Did you know you can also share workflows via the [KNIME hub](https://hub.knime.com/aseeber) now? 😉

---

<div class="post-metadata">

**Author:** ![scapuzzi](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/s/ecc23a/32.png) [@scapuzzi](https://forum.knime.com/u/scapuzzi)\
**Post date:** [July 13, 2020, 8:10pm UTC](https://forum.knime.com/t/correct-3d-drift-implementation-in-knime/25187/6 "2020-07-13T20:10:56Z")

</div>

this would be great on the knime hub! cheers,SC

---

<div class="post-metadata">

**Author:** ![aseeber](https://forum-cdn.knime.com/user_avatar/forum.knime.com/aseeber/32/13546_2.png) [@aseeber](https://forum.knime.com/u/aseeber)\
**Post date:** [July 14, 2020, 3:46am UTC](https://forum.knime.com/t/correct-3d-drift-implementation-in-knime/25187/7 "2020-07-14T03:46:41Z")

</div>

> [@imagejan](#):
>
> Thanks, Andrew, for sharing the example! The link requires me to request access, is that intended? Did you know you can also share workflows via the [KNIME hub](https://hub.knime.com/aseeber) now? 😉

Thanks for pointing that out. My academic google drive seems to have extra restrictions on sharing so I am glad KNIME hub exists: [link here](https://hub.knime.com/aseeber/spaces/Public/latest/Using%20the%20align%20node)

---

<div class="post-metadata">

**Author:** ![system](https://forum-cdn.knime.com/uploads/default/original/1X/ab3ccf34482a0329361734a18199390177204f15.png) [@system](https://forum.knime.com/u/system)\
**Post date:** [July 21, 2020, 3:58am UTC](https://forum.knime.com/t/correct-3d-drift-implementation-in-knime/25187/8 "2020-07-21T03:58:21Z")

</div>

Closed on July 21, 2020, 3:58am UTC

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
