Register Virtual Stack Slices, reference image was not found

I’ve encountered an issue that I can’t seem to get around with the register virtual stack slices plugin in a jython script. Whenever I try to run the example script from the wiki, it cannot find the reference image in the source folder. It seems to read the correct file name, but it still returns the error “reference image was not found in the source folder”. If I change the reference_name to an image that does not exist, like “xtest.tif” rather than test.tif, the error shows me that the function reads the whole name of the image. But it still it does not register…

def virtualstack():

# source directory
source_dir = "C:\Users\Sverre\Desktop\Imageprocessing\Virtualstacks\Lif_Stack_Split_C0"
# output directory
target_dir = "C:\Users\Sverre\Desktop\Imageprocessing\Virtualstacks\Lif_Stack_Split_C0\Aligned"
# transforms directory
transf_dir = "C:\Users\Sverre\Desktop\Imageprocessing\Virtualstacks\Trans"

# reference image
reference_name = "\\test.tif"
# shrinkage option (false)
use_shrinking_constraint = 0
p = Register_Virtual_Stack_MT.Param()
# The "maximum image size":
p.sift.maxOctaveSize = 1024
# The "inlier ratio":
p.minInlierRatio = 0.05

Register_Virtual_Stack_MT.exec(source_dir, target_dir, transf_dir, 
reference_name, p, use_shrinking_constraint)


The image is definitely correctly named and in the correct folder… Does anyone have any clue what I can do? This little error effectively shuts down my whole script.

I tried it on a windows 7 and a windows 10 system, I don’t have any macs or linux systems to test it on readily available.

In the original script the reference_name is the reference image name only, e.g.:


You added whyever two backslashes as a reference_name:


which leads probably to a wrong filename which can’t be found.

This is the first thing I tried, and it seems that the script does expect a file separator.

This is when I remove both slashes.

And this is when I keep one slash.

I forgot to look on your paths.

If you are using a windows filepath use the “\\” as path seperator or a Java filepath with “/”:

For a real platform independence use the File.seperator API function:

In your case the paths with a single backslash will be interpreted wrong on windows.

1 Like

The single backslash was not a problem untill I tried running this script. I tried adding backslashes and nothing changed… Can you give an example of how you would write it to make it work?

Just a minor comment: the script expects a file separator at the end of the folder paths, not the reference file name, although I don’t think that’s the problem in your case.

I moved the file separators to the source folder name and got the following error:

No features model found for file 0: Lif_Stack_Split_C0_alignedLif_Stack_Split_C0_alignedtest.tif

And now this:


source_dir = “C:\\Users\\Sverre\\Desktop\\Imageprocessing\\Virtualstacks\\Lif_Stack_Split_C0\\”

But in the sources it is converted to:

source_dir = “C:/Users/Sverre/Desktop/Imageprocessing/Virtualstacks/Lif_Stack_Split_C0/”



Please update all script paths accordingly (target_dir, transf_dir)!

Thank you so much for your help Bio7, it works! I tried adding backslashes before with no luck, but I probably neglected to add to the end of the trans_dir… I didn’t know it saved transformations by default.