How to transform points locations (csv) with bigwarp

Hi, I dont have programming background. I would like to ask i have landmark correspondences for BigWarp
and I would like to have transformation parameters to calculate new coordinates for given pixel positions. I have find out the thin plate spline has the best output. I suppose i have initial coordinates x,y then i need transformations dx,dy so i can calculate new positions x+dx and y+dy.

Summary

This text will be hidden
foto is 6240x4160px
landmarks moje.csv (94.5 KB)

Hi @Bjj,

Welcome to the forum.

This script is probably the easiest way to apply the bigwarp transform to arbitrary points.

There’s more information on this wiki page, in the section called “Warp points in a csv file”. If you still have questions after reading that, please write back.

John

I have already tried, with error

ERROR] jdk.nashorn.internal.runtime.ParserException: Scripts/Bwarpcsv.js:13:0 Expected an operand but found import
import [java.io](http://java.io/).*;
^
at jdk.nashorn.internal.parser.AbstractParser.error(AbstractParser.java:294)
at jdk.nashorn.internal.parser.AbstractParser.error(AbstractParser.java:279)

I don’t know if the structure of landmarks is the same as BigWarp or different
Pt-0,“true”,“336.995”,“31.87”,“326.117”,“24.985”
Pt-1,“true”,“381.35”,“31.525”,“371.059”,“24.995”
Pt-2,“true”,“781.993”,“27.64”,“776.111”,“25.08”

and scripts wants also csv output file so I don’t know what structure shall be input csv and output csv
I tried this structure
1563,2392,0
2062,2381,0
2934,2409,0

Hi @Bjj,

It looks like you tried running that script as javascript?

which is not right. Make sure the file extension is .groovy.

Learn about the fiji script editor here:

If you use that, copy the stuff in that file and make sure you select Groovy under the Language menu.

John

OK, thank you. But now the error is therefore I ask what is the data structure of landmarks, csv input and csv output. Is it right what I have written before?

net.imglib2.realtransform.InverseRealTransform@724e898f
[ERROR] java.lang.ArrayIndexOutOfBoundsException
at java.lang.System.arraycopy(Native Method)
What does it mean the sentence?
Csv files storing bigwarp landmarks will not work as input to this script.

Correct. Your csv should be “plain”, more like this (which you tried before):

Except make sure you have the same number of columns as the dimensionality of your images. It looks like you used 2d images*, so your csv should have only two columns.

John

*Since the Bigwarp csv you posted has only 4 numeric columns at the end (moving-x, moving-y, target-x, target-y)

I used this structure of landmarks. I have 1678 landmarks pairs.
336.995,31.87,326.117,24.985
381.35,31.525,371.059,24.995
781.993,27.64,776.111,25.08
826.98,27.541,821.053,25.09
and this structure of input csv this can have e.g. 200 different coordinates
5543.5,1162.5
5697.5,1194.5
3223.5,1200.5
645.5,1207.5
431.5,1240.5
4326.5,1384.5
4336.5,1384.5
2729.5,1398.5
2840.5,1399.5
2734.5,1533.5

null
[ERROR] java.lang.NullPointerException: Cannot invoke method apply() on null object

The landmarks have to be a file exported by bigwarp. It has to look something like this:

~1600 is a lot of landmarks by the way, did you click all of these yourself?

Or is the issue that you want to use landmark pairs generated in some other way? If this is the case, please say so and I can make a script to do this.

Please be as clear as you can about describing what you’re doing. The more detail you give, the more likely we are to be able to help quickly.

John

Hi John, I already have landmark pairs and I want to transform, using thin plate spline initial x,y, coordinates to new coordinates based on these landmark pairs. I have not used BigWarp to obtain these landmarks, I prepared own landmarks and modified them to BigWarp structure csv. I used these landmarks in BigWarp to transform the picture of 26 Mpx which took 6.5 minute. And this worked. But now I want only transform coordinates without transforming pictures based on my own landmarks.

Still, there is an error
net.imglib2.realtransform.InverseRealTransform@3f393a3d
java.nio.file.AccessDeniedException: C:\Users\

@Bjj

I’ve done something that may help you. ’

The script below takes two csvs - one for moving and one for target points, and creates a bigwarp landmark csv file.

John

p.s. Read more about scripting in fiji here.