backward compatible with nixio 1.5.0b3?
Closed this issue · 4 comments
Hello nixio community,
a file, saved with nixio 1.5.0b3, cannot be loaded with 1.5.0b4. Is this a known issue?
wget -N https://web.gin.g-node.org/INM-6/elephant-data/raw/master/dataset-2/asset_showcase_500.nix
with neo.NixIO('asset_showcase_500.nix', 'ro') as f:
block = f.read_block()
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-4-c2dd4bfdbe67> in <module>
----> 1 with neo.NixIO('asset_showcase_500.nix', 'ro') as f:
2 block = f.read_block()
3 segment = block.segments[0]
4 spiketrains = segment.spiketrains
~/anaconda3/envs/elephant/lib/python3.7/site-packages/neo/io/nixio.py in __init__(self, filename, mode)
162 self._file_version = '0.5.2'
163 if "neo" in self.nix_file.sections:
--> 164 self._file_version = self.nix_file.sections["neo"]["version"]
165 elif self.nix_file.mode == nix.FileMode.ReadWrite:
166 if "neo" in self.nix_file.sections:
~/anaconda3/envs/elephant/lib/python3.7/site-packages/nixio/section.py in __getitem__(self, key)
456
457 prop = self.props[key]
--> 458 values = list(prop.values)
459 if len(values) == 1:
460 values = values[0]
~/anaconda3/envs/elephant/lib/python3.7/site-packages/nixio/property.py in values(self)
241 x, y, z = dataset._parent.file.attrs["version"]
242 if x < 1 or (x == 1 and y < 1) or (x == 1 and y == 1 and z < 1):
--> 243 v = self._read_old_values()
244 return v
245 if not sum(dataset.shape):
~/anaconda3/envs/elephant/lib/python3.7/site-packages/nixio/property.py in _read_old_values(self)
232 val_tu = tuple()
233 for v in val:
--> 234 v = v["value"]
235 val_tu += (v,)
236 return val_tu
TypeError: string indices must be integers
This is a known issue and part of it is a bug in the b3
release that changed the way metadata values are stored but the file version header wasn't updated to reflect this. The next release will include a script to upgrade older files to new formats and fix such inconsistencies.
For now, the best way to work with the file would be to install v1.5.0b3. Alternatively, you could try the master branch and use the upgrade script on the file to test the unrealeased up to date version of the library, but of course for that I would strongly recommend you keep backups of all files and data you work with.
Thank you.
I'll wait for the next release and try upgrading the file.
The latest beta release (v1.5.0b6) includes the script I mentioned, which upgrades older files to newer formats.
Keep in mind this is a beta release and, while we do our best to test any changes thoroughly, there is always the possibility of bugs. If you plan to use the upgrade script on your files, make sure to run it on copies of the primary files and keep backups.
You're right. I better wait for a stable release, convert the file, and fix the requirement version.
I think this issue should no longer be open.
I'll open an issue if I encounter a problem while converting the file.