Importing Landmarks from excel file into 3D Slicer


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

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

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:


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:


Example .csv file with all supported fields: