Skip to content

Instantly share code, notes, and snippets.

@npyoung
Last active October 11, 2015 07:30
Show Gist options
  • Save npyoung/a2d9784929716225fc24 to your computer and use it in GitHub Desktop.
Save npyoung/a2d9784929716225fc24 to your computer and use it in GitHub Desktop.
Convert a Tucker-Davis Technologies (TDT) to Neo's HDF5 format
from os.path import join as pjoin
from os.path import isdir
from os import listdir
from argparse import ArgumentParser
from neo.io import TdtIO, NeoHdf5IO
from progressbar import ProgressBar
if __name__ == '__main__':
parser = ArgumentParser(description="Convert a Tucker-Davis Technologies (TDT) to Neo's HDF5 format.")
parser.add_argument('datatank', type=str, help="Path to the DataTank root")
parser.add_argument('output', type=str, help="Path to the h5 file you want to create")
args = parser.parse_args()
tank = TdtIO(filename=args.datatank)
h5file = NeoHdf5IO(filename=args.output)
segment_names = [name for name in listdir(args.datatank) if isdir(pjoin(args.datatank, name))]
for segment_name in ProgressBar()(segment_names):
h5file.write_segment(tank.read_segment(segment_name))
@npyoung
Copy link
Author

npyoung commented Oct 11, 2015

This assumes NeuralEnsemble/python-neo#213 gets merged. Doing this by the whole block (as opposed to segment-by-segment) will likely run you out of memory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment