Binary File CSV

How would you go about saving a csv file, or xml file for a binary labelmpa for use in other softwares, etc. Where every pixel with a 1 is tagged in the file with the x, y and z dimensions, etc.?

We usually don’t do that because the file would be quite large, but you could get the data which something like:

labelarray = array('MRHead-label')
import numpy
numpy.where(labelarray==1)

you’ll get three lists of coordinates that you can write out in whatever format you need.

What about reading in such a CSV file and creating a binary, is that possible?

You easily can do all that in Python.

However, this file format of listing non-zero voxels only makes sense if you have a very low number of points (up to maybe a few ten thousands), because otherwise it would be very slow to read and write the file. Why do you consider using this file format? If the problem is that you have very sparse data and file storage is not efficient then you can store the labelmap volume with zip compression. Compressed nrrd file readers and writers are available in all relevant programming languages and environments.