# Segmented NRRD File is 0 Bytes After Editing

**URL:** <https://discourse.slicer.org/t/segmented-nrrd-file-is-0-bytes-after-editing/36387>\
**Category:** Development\
**Tags:** segmentation, python\
**Created:** [May 25, 2024, 1:46pm UTC](https://discourse.slicer.org/t/segmented-nrrd-file-is-0-bytes-after-editing/36387 "2024-05-25T13:46:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![DrBorg](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/drborg/32/70248_2.png) [@DrBorg](https://discourse.slicer.org/u/DrBorg)\
**Post date:** [May 25, 2024, 1:46pm UTC](https://discourse.slicer.org/t/segmented-nrrd-file-is-0-bytes-after-editing/36387/1 "2024-05-25T13:46:08Z")

</div>

Hello,

I’m working with a segmented NRRD file and I’m trying to remove certain segments. I wrote the script, shown below, to do this.

It appears to work, however, the output SEG.NRRD outputs the following error when opened:  
**This NRRD file contains non-short and non-byte data. Short or char data formats are required.**

Any thoughts? Thank you!

```auto
# Imports
import slicerio
import nrrd

# Pre-defined Variables
nrrd_file_path = r"\Python Scripts\CTChest segmentation.seg.nrrd"
save_path = r"\Python Scripts\CTChest segmentation EDITED.seg.nrrd"
segment_names_to_labels = [('L3 vertebra', 20), ('L2 vertebra', 21), ('L1 vertebra', 22)]

# Load the existing NRRD file
voxels, header = nrrd.read(nrrd_file_path)

# Obtain NRRD segmentation information
segmentation_info = slicerio.read_segmentation_info(nrrd_file_path)

# Save new file with extracted data
extracted_voxels, extracted_header = slicerio.extract_segments(voxels, header, segmentation_info, segment_names_to_labels)
nrrd.write(save_path, extracted_voxels, extracted_header)

```
