# Batch Structure Set Conversion

**URL:** <https://discourse.slicer.org/t/batch-structure-set-conversion/4635>\
**Category:** Support\
**Created:** [November 5, 2018, 9:53am UTC](https://discourse.slicer.org/t/batch-structure-set-conversion/4635 "2018-11-05T09:53:45Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![stine](https://avatars.discourse-cdn.com/v4/letter/s/bbe5ce/32.png) [@stine](https://discourse.slicer.org/u/stine)\
**Post date:** [November 5, 2018, 9:53am UTC](https://discourse.slicer.org/t/batch-structure-set-conversion/4635/1 "2018-11-05T09:53:45Z")

</div>

Hi!

Since PyRadiomics does not support DICOM-RTSTRUCT as input mask, I am trying to convert the files to labelmaps (.nrrd files). I have more than 100 files, so I was hoping to do this using a batch processing script. I found the BatchStructureSetConversion.py-file and tried the following:

/Applications/Slicer.app/Contents/MacOS/Slicer --no-main-window --python-script [MyPath/]BatchStructureSetConversion.py --input-folder [MyPath] --output-folder [MyPath]

However, this produces only one .nrrd file (size: 9x10x12), and the size/dimensions does not correspond to that of the PET images…

My input folder contains one subfolder for each patient where the PET DICOM-RT files and the DICOM-RTSTRUCT file are stored together (data from the MICCAI 2018 PET Radiomics Challenge). Could the problem be the folder structure or the file types? I am really stuck on this problem and any help would be much appreciated!

Best regards,  
Stine

Slicer version: 4.10.0

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [November 5, 2018, 1:15pm UTC](https://discourse.slicer.org/t/batch-structure-set-conversion/4635/2 "2018-11-05T13:15:06Z")

</div>

Hi -

I assume you are talking about [this script](https://github.com/SlicerRt/SlicerRT/blob/master/BatchProcessing/BatchStructureSetConversion.py), right? Since this is public data, it would be great if you can set up a simple test case that’s easy to reproduce and file an issue.

Ideally your test case should automatically download the data files to reproduce the issue, but if that’s not feasible for you at least include links to the data and the specific versions of the code you are using and the exact steps to reproduce.

Thanks!

---

<div class="post-metadata">

**Author:** ![stine](https://avatars.discourse-cdn.com/v4/letter/s/bbe5ce/32.png) [@stine](https://discourse.slicer.org/u/stine)\
**Post date:** [November 5, 2018, 2:08pm UTC](https://discourse.slicer.org/t/batch-structure-set-conversion/4635/3 "2018-11-05T14:08:35Z")

</div>

Thank you so much for the quick reply! That’s the script, yes.

I’m sorry but I’m very new to this and I don’t know how to set up that type of test case. I have downloaded a folder (named Training) containing a number of subfolders (one for each patient) where the PET slices and the segmentation contour data (.DCM file) are stored together. I’m trying to obtain a labelmap/binary segmentation mask for each patient.

Here is the link to the data I’m using (the Training.zip-folder): [https://www.kaggle.com/c/pet-radiomics-challenges/data](https://www.kaggle.com/c/pet-radiomics-challenges/data).

I have the latest version of the BatchStructureSetConversion.py script and I used the entire Training-folder as input:

/Applications/Slicer.app/Contents/MacOS/Slicer --no-main-window --python-script [path/to/batch-script/]BatchStructureSetConversion.py --input-folder [path/to/Training-folder] --output-folder [path/to/empty/folder]

I hope that this helps explaining my problem.

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [November 5, 2018, 2:49pm UTC](https://discourse.slicer.org/t/batch-structure-set-conversion/4635/4 "2018-11-05T14:49:29Z")

</div>

Do you see any errors in the output or the log?

---

<div class="post-metadata">

**Author:** ![stine](https://avatars.discourse-cdn.com/v4/letter/s/bbe5ce/32.png) [@stine](https://discourse.slicer.org/u/stine)\
**Post date:** [November 5, 2018, 6:58pm UTC](https://discourse.slicer.org/t/batch-structure-set-conversion/4635/5 "2018-11-05T18:58:22Z")

</div>

When I run the script on a subset of 3 patients (HN-MICCAI2018-0002, HN-MICCAI2018-0004 and HN-MICCAI2018-0005) I get the following output (in addition to one .nrrd file):

Import DICOM data from /Users/stine/PycharmProjects/radiomics/data/PET/TrainingSUB  
Switching to temporary DICOM database: /var/folders/1p/dw77r3v93yvbpqkp6vj9wtnm0000gn/T/Slicer-stine/20181105\_185446\_TempDICOMDatabase  
Original DICOM database: /var/folders/1p/dw77r3v93yvbpqkp6vj9wtnm0000gn/T/Slicer-stine/20181105\_184533\_TempDICOMDatabase  
Failed to obtain reference to ‘qSlicerMainWindow’  
Failed to obtain reference to ‘qSlicerMainWindow’  
QSqlDatabasePrivate::removeDatabase: connection ‘SLICER’ is still in use, all queries will cease to work.  
QSqlDatabasePrivate::addDatabase: duplicate connection name ‘SLICER’, old connection removed.  
TagCacheDatabase adding table

QSqlDatabasePrivate::removeDatabase: connection ‘SLICER’ is still in use, all queries will cease to work.  
QSqlDatabasePrivate::addDatabase: duplicate connection name ‘SLICER’, old connection removed.  
QSqlDatabasePrivate::removeDatabase: connection ‘SLICER’ is still in use, all queries will cease to work.  
QSqlDatabasePrivate::addDatabase: duplicate connection name ‘SLICER’, old connection removed.  
Failed to obtain reference to ‘qSlicerMainWindow’  
Could not find main window  
Could not find moduleSelector in the main window  
E: DcmElement: CommandField (0000,0100) larger (828667202) than remaining bytes in file  
Could not load “/Users/stine/PycharmProjects/radiomics/data/PET/TrainingSUB/.DS\_Store”  
DCMTK says: I/O suspension or premature end of stream  
Could not read DICOM file:/Users/stine/PycharmProjects/radiomics/data/PET/TrainingSUB/.DS\_Store  
New patient inserted: 1  
New patient inserted as : 1  
Need to insert new study: “1.3.6.1.4.1.14519.5.2.1.1707.8040.916101888211223106723732084398”  
Study Added  
Need to insert new series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.276182720375307817025066820423”  
Series Added  
E: DcmElement: CommandField (0000,0100) larger (828667202) than remaining bytes in file  
Could not load “/Users/stine/PycharmProjects/radiomics/data/PET/TrainingSUB/HN-MICCAI2018-0002/.DS\_Store”  
DCMTK says: I/O suspension or premature end of stream  
Could not read DICOM file:/Users/stine/PycharmProjects/radiomics/data/PET/TrainingSUB/HN-MICCAI2018-0002/.DS\_Store  
New patient inserted: 2  
New patient inserted as : 2  
Need to insert new series: “1.2.276.0.7230010.3.1.4.4252153939.211348.1528745918.141”  
Series Added  
Found patient in the database as UId: 1  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.276182720375307817025066820423”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.276182720375307817025066820423”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.276182720375307817025066820423”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.276182720375307817025066820423”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.276182720375307817025066820423”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.276182720375307817025066820423”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.276182720375307817025066820423”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.276182720375307817025066820423”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.276182720375307817025066820423”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.276182720375307817025066820423”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.276182720375307817025066820423”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.276182720375307817025066820423”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.276182720375307817025066820423”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.276182720375307817025066820423”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.276182720375307817025066820423”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.276182720375307817025066820423”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.276182720375307817025066820423”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.276182720375307817025066820423”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.276182720375307817025066820423”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.276182720375307817025066820423”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.276182720375307817025066820423”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.276182720375307817025066820423”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.276182720375307817025066820423”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.276182720375307817025066820423”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.276182720375307817025066820423”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.276182720375307817025066820423”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.276182720375307817025066820423”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.276182720375307817025066820423”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.276182720375307817025066820423”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.276182720375307817025066820423”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.276182720375307817025066820423”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.276182720375307817025066820423”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.276182720375307817025066820423”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.276182720375307817025066820423”  
Series Added  
New patient inserted: 3  
New patient inserted as : 3  
Need to insert new study: “1.3.6.1.4.1.14519.5.2.1.1707.8040.338589861935722567365981799683”  
Study Added  
Need to insert new series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.397286022729450579606108175191”  
Series Added  
New patient inserted: 4  
New patient inserted as : 4  
Need to insert new series: “1.2.276.0.7230010.3.1.4.4252153939.211348.1528746083.145”  
Series Added  
Found patient in the database as UId: 3  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.397286022729450579606108175191”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.397286022729450579606108175191”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.397286022729450579606108175191”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.397286022729450579606108175191”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.397286022729450579606108175191”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.397286022729450579606108175191”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.397286022729450579606108175191”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.397286022729450579606108175191”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.397286022729450579606108175191”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.397286022729450579606108175191”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.397286022729450579606108175191”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.397286022729450579606108175191”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.397286022729450579606108175191”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.397286022729450579606108175191”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.397286022729450579606108175191”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.397286022729450579606108175191”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.397286022729450579606108175191”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.397286022729450579606108175191”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.397286022729450579606108175191”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.397286022729450579606108175191”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.397286022729450579606108175191”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.397286022729450579606108175191”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.397286022729450579606108175191”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.397286022729450579606108175191”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.397286022729450579606108175191”  
Series Added  
New patient inserted: 5  
New patient inserted as : 5  
Need to insert new study: “1.3.6.1.4.1.14519.5.2.1.1707.8040.563642908585179401817164347275”  
Study Added  
Need to insert new series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.338955629943308958335236734341”  
Series Added  
New patient inserted: 6  
New patient inserted as : 6  
Need to insert new series: “1.2.276.0.7230010.3.1.4.4252153939.211348.1528746059.143”  
Series Added  
Found patient in the database as UId: 5  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.338955629943308958335236734341”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.338955629943308958335236734341”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.338955629943308958335236734341”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.338955629943308958335236734341”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.338955629943308958335236734341”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.338955629943308958335236734341”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.338955629943308958335236734341”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.338955629943308958335236734341”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.338955629943308958335236734341”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.338955629943308958335236734341”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.338955629943308958335236734341”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.338955629943308958335236734341”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.338955629943308958335236734341”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.338955629943308958335236734341”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.338955629943308958335236734341”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.338955629943308958335236734341”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.338955629943308958335236734341”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.338955629943308958335236734341”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.338955629943308958335236734341”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.338955629943308958335236734341”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.338955629943308958335236734341”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.338955629943308958335236734341”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.338955629943308958335236734341”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.338955629943308958335236734341”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.338955629943308958335236734341”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.338955629943308958335236734341”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.338955629943308958335236734341”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.338955629943308958335236734341”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.338955629943308958335236734341”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.338955629943308958335236734341”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.338955629943308958335236734341”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.338955629943308958335236734341”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.338955629943308958335236734341”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.338955629943308958335236734341”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.338955629943308958335236734341”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.338955629943308958335236734341”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.338955629943308958335236734341”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.338955629943308958335236734341”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.338955629943308958335236734341”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.338955629943308958335236734341”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.338955629943308958335236734341”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.338955629943308958335236734341”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.338955629943308958335236734341”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.338955629943308958335236734341”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.338955629943308958335236734341”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.338955629943308958335236734341”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.338955629943308958335236734341”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.338955629943308958335236734341”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.338955629943308958335236734341”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.338955629943308958335236734341”  
Series Added  
Used existing series: “1.3.6.1.4.1.14519.5.2.1.1707.8040.338955629943308958335236734341”  
Series Added  
“DICOM indexer has successfully processed 298 files [1.90s]”  
Load first patient into Slicer  
reg inside examine  
W: OperatorsName (0008,1070) absent in RTSeriesModule (type 2)  
reg inside examine  
W: OperatorsName (0008,1070) absent in RTSeriesModule (type 2)  
Loading series ‘1: RTSTRUCT: MICCAI2018’ from file ‘/Users/stine/PycharmProjects/radiomics/data/PET/TrainingSUB/HN-MICCAI2018-0002/MICCAI2018.DCM’  
W: OperatorsName (0008,1070) absent in RTSeriesModule (type 2)  
Loading with imageIOName: GDCM  
Window/level found in DICOM tags (center=6857.729132, width=13715.458265) has been applied to volume 65690: LOR-RAMLA  
Irregular volume geometry detected, but maximum error non-zero but is within tolerance (maximum error of 8.00488e-06 mm, tolerance threshold is 0.001 mm).  
Convert loaded structure set to labelmap volumes  
Converting structure set 1: RTSTRUCT: MICCAI2018  
Save labelmaps to directory /Users/stine/PycharmProjects/radiomics/data/PET/TrainingNRRD  
Saving structure 1: RTSTRUCT: MICCAI2018\_GTVp  
to file 1\_RTSTRUCT\_MICCAI2018\_GTVp.nrrd  
Generic Warning: In /Volumes/Dashboards/Stable/Slicer-4100/Libs/MRML/Core/vtkDataFileFormatHelper.cxx, line 237  
vtkDataFileFormatHelper::GetFileExtensionFromFormatString: please update deprecated extension-only format specifier to ‘File format name (.ext)’ format! Current format string: .nrrd

DONE  
Segmentation fault: 11

---

<div class="post-metadata">

**Author:** ![stine](https://avatars.discourse-cdn.com/v4/letter/s/bbe5ce/32.png) [@stine](https://discourse.slicer.org/u/stine)\
**Post date:** [November 7, 2018, 3:14pm UTC](https://discourse.slicer.org/t/batch-structure-set-conversion/4635/6 "2018-11-07T15:14:07Z")

</div>

I’m thinking that the folder structure and/or the file types might be the problem. What does the script expect? How should the data files be arranged within the input folder, and what format should the PET images have?

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [November 7, 2018, 3:53pm UTC](https://discourse.slicer.org/t/batch-structure-set-conversion/4635/7 "2018-11-07T15:53:16Z")

</div>

The folder you specify simply needs to contain DICOM data. The script creates a database there, imports all the DICOM in the folder, and processes each patient one by one. In each patient it will iterate through the structure sets, and within those the structures, and saves each as a labelmap with the geometry of the referenced anatomical image.

Unfortunately the log shows nothing interesting.

What happens if you:

- Open Slicer, open the DICOM browser
- Import one of the studies you want to convert
- Load the study to Slicer (make sure you have SlicerRT extension installed)
- Go to Segmentations module
- Open the section called Export/import models and labelmaps
- Open Advanced, make sure the reference volume is the anatomical image you want (let us know if it’s not the proper one by default)
- Click Export
- Show the resulting labelmap in the slice views. If you’re not sure how to do it then go to the Data module and click the show icon in the row of the labelmap ( called [StructureSetName]-label)

Does it look OK?

---

<div class="post-metadata">

**Author:** ![stine](https://avatars.discourse-cdn.com/v4/letter/s/bbe5ce/32.png) [@stine](https://discourse.slicer.org/u/stine)\
**Post date:** [November 7, 2018, 7:32pm UTC](https://discourse.slicer.org/t/batch-structure-set-conversion/4635/8 "2018-11-07T19:32:33Z")

</div>

Okey, but the input folder can contain subfolders for each patient?

The procedure described above produces a labelmap that looks good and the default reference volume is correct (there is only one option except for the “None”-option).

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [November 7, 2018, 9:24pm UTC](https://discourse.slicer.org/t/batch-structure-set-conversion/4635/9 "2018-11-07T21:24:32Z")

</div>

I don’t think it matters how the folders are arranged within the input folder. As long as it can be imported into a DICOM database, it’s fine.

Batch Structure Set Conversion works basically the same way the steps above that produced a good labelmap. So not sure what goes wrong with your data without seeing it.
