Convert CSV files to be loadable as Fiducials or as Sequence of Fiducials (JSON)

Hi,
I have several CSV files which contain nodal coordinates of a finite element mesh at different time-points after finite element analysis.

I want to validate the FE-model with echocardiography, and therefore want to import the CSV’s into Slicer and plot it together with the echocardiographic volume. Preferably as fiducial markers, and if possible in a Sequence which is loadable. However, JSON files that could be imported as fiducials would do just fine.

The CSV format currently looks like this, but if another format is better this can change.

0.020008288323879242,0.020008288323879242,0.020008288323879242
-5.5104074478149405,21.592485427856445,11.360527992248535
-3.809137344360352,20.855607986450195,11.380624771118164
-2.173929452896118,20.26450729370117,11.737421989440916
-0.4237257242202759,19.472154617309567,12.046059608459473
1.1728017330169676,18.723459243774414,12.897193908691408
3.3027710914611816,19.262800216674805,13.48173522949219
5.7919020652771,22.181146621704098,11.295902252197264
7.3409905433654785,19.74334526062012,6.751131057739258
5.514996528625488,17.492221832275387,5.892641067504882

Here the first row contains the time during FEA, at the X,Y,Z coordinate. Meaning that each column describes the X,Y,Z coordinate respectively.

If someone has any tips on how this could be done, it would be very appreciated.

Best
Hans Martin

In recent Slicer Preview Releases, you can use the table import feature in Markups module.

All you need to do is to create a valid csv file from this, by adding a header. If the coordinates are in LPS coordinate system then add l,p,s as column names, if the coordinates are in RAS then use r,a,s. For example:

r, a, s
0.020008288323879242,0.020008288323879242,0.020008288323879242
-5.5104074478149405,21.592485427856445,11.360527992248535
-3.809137344360352,20.855607986450195,11.380624771118164
-2.173929452896118,20.26450729370117,11.737421989440916
-0.4237257242202759,19.472154617309567,12.046059608459473
1.1728017330169676,18.723459243774414,12.897193908691408
3.3027710914611816,19.262800216674805,13.48173522949219
5.7919020652771,22.181146621704098,11.295902252197264
7.3409905433654785,19.74334526062012,6.751131057739258
5.514996528625488,17.492221832275387,5.892641067504882

You can then save this file as .csv and use it as control point coordinates in Slicer:

  • drag-and-drop the .csv file on the Slicer application window and click “Apply” to load it as a table
  • go to Markups module
  • create a markup node (fiducial list, curve, …)
  • in “Export/import table” section choose “Import” and select the input table
  • click “Import”

There are a couple of more columns that you can add, such as point labels or selected state. See a complete list here.

If you want to import a markup directly from a file and/or specify markup display properties (colors, opacities, glyph size, …) then you can create a .mrk.json file. See more information here.

1 Like

Thank you! That worked perfectly.
HM

1 Like

Hi Lassoan, did you mean to use l,p,s as a header if the coords system is LPS in the .csv file? Is it a typo that you wrote " If the coordinates are in LPS coordinate system then add r,a,s as column names, if the coordinates are in RAS then use r,a,s ." ?
Thank you, this is important to me.

Sorry, the that was just a typo (I’ve fixed it now).

Use column names that match the coordinate system axis names.