Importing Landmarks from excel file into 3D Slicer

Hello,

I have an excel sheet with landmarks specified I believe in itk-snap . As suggested here: Export formats for markups - #6 by muratmaga
I saved as .csv file (excel doesn’t have .fcsv) and added the suggested code to the beginning of the file but only a table with ID’s get exported. I don’t know how to change the code to read my headers.
the file can be found here https://drive.google.com/file/d/1ERvpmIvjQEQuFQe18L-37ymFTrK6qUVK/view?usp=sharing

Thanks for any hint.

In that thread, original poster has the data in the correct format with all the field, and while saving as csv, they accidentally removed the special fcsv header. So pasting it, fixed the problem.

That won’t work for you, as you will need to rearrange your data. Currently you have each sample in a row. You will have to convert data such that each specimen is a single fcsv, where the each row is a single landmark. This is best done programmatically.

If you an R user, you can do devtools::install_packages(‘SlicerMorph/SlicerMorphR’) and then use the write.markups.fcsv() function to write fcsv files (after you rearrange the data in the way described above).

Thanks a lot for your reply. Sorry I’m not familiar ,where should I use this devtools::install_packages(‘SlicerMorph/SlicerMorphR’)

That’s an R package. If you are not familiar with R, you can disregard.

You can reorganize the data manually as well.

I reorganized the data with excel formulas and tried to import the csv file. Slicer import it as a table and reads the data but in the fiducial registration wizard doesn’t recognize the fiducial file.

There are some differences between fcsv and csv file. For example, this is what fcsv file looks like containing a single LM (F-1) located at coordinates 1, 2, 3

# Markups fiducial file version = 4.11
# CoordinateSystem = LPS
# columns = id,x,y,z,ow,ox,oy,oz,vis,sel,lock,label,desc,associatedNodeID
1,1,2,3,0,0,0,1,1,1,0,F-1,,

You have to edit your csv file using this format, then rename them as fcsv and you should be able to read it into Slicer as markups (as oppose to take) correctly.

1 Like

As a quick experiment, I’ve implemented table export/import feature in Markups module. This allows conversion between CSV files and markups control points.

There could be many things to improve related to this, such as:

  • import/export from/to clipboard
  • flexible column mapping
  • option to clear out the target node before adding the new points (currently points are always appended)
  • export/import all control point measurements - curvature, etc.
  • add a mode to import/export measurements instead of control points
  • save markups name and type to the table so that many markups can be stored in a single table
  • allow loading csv file directly as markups

Implementing all these would be a lot of work, but I may be able find time to implement a few of those, so it would be useful to get feedback on which features are wanted the most.

1 Like

FYI, the table export/import is available in today’s Slicer Preview Release. Any feedback is welcome.

I just tried and got this error message:

"Table" Reader has successfully read the file "C:/Users/murat/Desktop/test_table.csv" "[0.01s]"
setViewLabel should be called before setViewNode !
setViewLabel should be called before setViewNode !
setViewLabel should be called before setViewNode !
setViewLabel should be called before setViewNode !
Switch to module: "Markups"
Generic Warning: In D:\D\P\Slicer-0\Modules\Loadable\Markups\Logic\vtkSlicerMarkupsLogic.cxx, line 1748
vtkSlicerMarkupsLogic::ImportControlPointsFromTable failed: Invalid markupsNode or tableNode.

Markups node is populated, but they are 0,0,0

here are the contents of the csv file:

|M1|-9.150921822|-22.86759949|7.407970428|
|M2|-9.103624344|-25.06776237|10.3398838|
|M3|-7.095143318|-18.17201233|11.3801918|
|M4|-9.170223236|-17.20416832|11.93351269|
|M5|-9.065729141|-17.70404434|11.78754807|
|M6|-9.344167709|-16.48130608|7.361549377|
|M7|-11.22470284|-18.25616074|11.31808662|
|M8|-3.935972214|-15.5256691|8.035143852|
|M9|-14.49450397|-15.58605385|7.946472645|
|M10|-3.270830631|-12.43230247|6.841721535|
|M11|-6.151437759|-12.95347023|11.44103241|
|M12|-12.09773731|-12.9262743|11.54073048|
|M13|-15.24338341|-12.45711899|6.929478645|
|M14|-8.975575447|-9.588539124|11.80789948|
|M15|-9.160082817|-5.779891491|10.60149002|
|M16|-9.007077217|-2.824546337|8.692295074|
|M17|-6.019548416|-17.7469883|10.51934433|
|M18|-6.579883575|-19.12015343|7.670481682|
|M19|-6.695315361|-13.83416176|11.27579689|
|M20|-6.948893547|-12.08451462|5.264913559|
|M21|-3.752249718|-8.844957352|7.841619968|
|M22|-5.002905846|-5.621376514|8.7119627|
|M23|-11.12182045|-20.84689522|9.683402061|
|M24|-12.28719139|-17.59350777|10.56907272|
|M25|-11.69880581|-13.72665119|11.33343792|
|M26|-12.64149475|-12.85103416|8.05005455|
|M27|-14.40844536|-8.798666|7.85973835|
|M28|-13.38345718|-5.59616518|8.764681816|
|M29|-8.828820229|-22.00113678|7.368155479|
|M30|-12.3915844|-18.19547272|9.618013382|
|M31|-7.220074654|-17.74337578|7.051663876|
|M32|-10.33326912|-20.38110733|7.131398201|
|M33|-9.389846802|-22.01970482|7.390283585|
|M34|-11.49119377|-19.4066124|7.344583511|
|M35|-7.708600044|-20.17664719|7.100816727|
|M36|-8.358551025|-20.27204132|7.255236626|
|M37|-7.177659035|-20.56736755|9.717757225|
|M38|-9.757544518|-16.44082642|6.664048672|
|M39|-6.000197411|-18.1774292|9.445129395|
|M40|-11.01899815|-17.78924561|6.879428387|
|M41|-8.738926888|-16.73945427|6.708190918|
|M42|-9.848192215|-15.44428253|6.469041348|
|M43|-7.845579147|-14.36761284|5.635435581|
|M44|-8.55123806|-15.80703354|6.548315525|
|M45|-14.98413658|-13.41439247|6.521261215|
|M46|-9.265712738|-13.31762218|5.219259262|
|M47|-10.74543667|-13.94102669|5.519832611|
|M48|-7.185830116|-13.74380779|5.619788647|
|M49|-3.381908178|-13.40026093|6.416231632|
|M50|-14.70256138|-11.20371246|7.282434464|
|M51|-11.40052605|-11.96435547|5.255110264|
|M52|-9.004154205|-15.01675415|6.191643715|
|M53|-3.735332012|-11.28477383|7.158238888|
|M54|-8.945774078|-8.538723946|4.375735283|
|M55|-9.213869095|-5.81755352|3.644111633|

This is not a csv (comma-separated value) file. In a csv file, values are separated by commas. Header row is missing, so there is no way of knowing what field corresponds to what.

Expected column names are display as tooltip of the import option, but probably the simplest is to export a markup to a table and save it to file and then have a look at the file.

Minimal .csv file example:

label,r,a,s
F-1,79.3014,17.4631,-10.2143
F-2,-32.809,-33.7369,-10.2143
F-3,-0.146917,6.9286,18.8581

Example .csv file with all supported fields:

label,r,a,s,defined,selected,visible,locked,description
F-1,79.3014,17.4631,-10.2143,1,1,1,0,
F-2,-32.809,-33.7369,-10.2143,1,1,1,0,
F-3,-0.146917,6.9286,18.8581,1,1,1,0,