I've been having a bit of trouble with python correctly reading a binary file output by neuron. Neuron records the data as follows:
Code: Select all
strdef outdir, fprefix
outdir = "./data"
fprefix = "test"
strdef filename
objref runfile
runfile = new File()
sprint(filename,"%s/%s.dat",outdir,fprefix)
runfile.wopen(filename)
runfile.seek(0)
// for each section, output header and data
//output somatic section header
runfile.printf("%s", "soma") // sec_list_name
runfile.printf("%d", 1) // num_sections
Code: Select all
def read_list_header(self):
sec_list_name = self.file.read(4)
self.file.seek(4,1)
num_sections = struct.unpack('i', self.file.read(4))[0]
self.file.seek(4,1)
return (sec_list_name, num_sections)
I'm not sure if the issue is with Neuron storing this value, or with python retrieving it.