Batch Processing Method for Json Files in Separate Folders

Operating system: MacOS 15.0, Apple M3, RAM 16 GB
Slicer version: macOS 5.6.2

Hi all,

I have been using slicer to segment two facial muscles on individual nrrd files exported from CT scans. I have measured each muscle with curves using the Markup tool, and have kept them in individual folders (Folder 1 = 1.nrrd, 1.segmentation-1.nrrd, 1.segmentation-2.nrrd, curves.json). I now aim to record the lengths of all curves measured. However, I have 600 curves to obtain length data from. (100 files, 6 curves per file).

Is there a batch processing method to do this? Or in the least, export a CSV file per folder? My final goal is to congregate all datapoints into one CSV file. I am new to slicer .

Thank you in advance!

Following this example in the python script repo, you can get the length from the curve filename using:

pip_install("pandas")
import pandas as pd
length = pd.DataFrame.from_dict(pd.read_json("your_json_path"))['markups'][0]['measurements'][0]['value']

This will work if you already have the curve length in the JSON file. If you don’t have this, I can follow up with some pointers on automating this.

Thank you so much for your help! Success!