ROI issue after registration correction

I have a large group of images which have many ROIs identified by thresholding and some binary processing. Different regions of the image experience different degrees of movement artifact and I’m attempting to register correct every ROI individually using the [Correct 3D Drift Plugin in FIJI]. When i correct the registration of the area the old ROI no longer correlates with the same area (see example image). Is there a method that will perfectly realign my ROI on the new image? Because I have a lot of data I’m trying to generate a macro that will automatically perform the analysis and I’ve gotten nearly everything to work except this.

The Correct 3D Drift Plugin has a readout in the IJ Log; for example, “frame 60 correcting drift 5.0,-6.0,0.0”. If I were able to adjust the ROI based on those x,y values I should be able to correct the ROI position.

1 Like

Hi @mcarvin,

check
https://imagej.nih.gov/ij/developer/macro/functions.html

for ROI Functions and ROI Manager Functions.

These 3 commands should help:
roiManager(“select”, index)
Roi.move(x, y)
roiManager(“update”)

2 Likes

Thanks @phaub,

Yes, I think you’re right about the ROI macro functions. In order to automate this it seems that I may have to use a split(string, delimiters) function to parse out the x and y values from the log output? I’ve never done this and have limited experience in writing code…

1 Like

@mcarvin Yes, if the log output is the only information you have you need to parse it.

Beside split(string, delimiters) there are other important macro functions such as:
https://imagej.nih.gov/ij/download/tools/source/macros/functions.html#substring
https://imagej.nih.gov/ij/download/tools/source/macros/functions.html#indexOf

To load the content of the log window into a variable check this

2 Likes

Update on the issue -

I haven’t been able to pull out the info from the log using the functions we’ve discussed. However, I have determined a work-around using the Auto Crop feature to remove the change in dimension after registration.

Unfortunately, and I don’t know why, I lose a time-point from my hyperstack when I run the autocrop function… FIJI throws an exception at me (see image). Does anyone know why or how to prevent this?

Untitled.tiff (84.1 KB)