swharden / pyABF

pyABF is a Python package for reading electrophysiology data from Axon Binary Format (ABF) files

Home Page:https://swharden.com/pyabf

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

abf.fileGUID has 1 incorrect byte

swharden opened this issue · comments

ABF GUIDs have a typo in the array that produces a GUID that is wrong by two hex characters. The last few digits of the first array should be 13, 14, 15.

# format GUID
guid = []
for i in [3, 2, 1, 0, 5, 4, 7, 6, 8, 9, 10, 11, 12, 13, 15, 15]:
guid.append("%.2X" % (self.uFileGUID[i]))
for i in [4, 7, 10, 13]:
guid.insert(i, "-")
self.sFileGUID = "{%s}" % ("".join(guid))

This change may break production code which relies on GUIDs previously generated by pyABF. This is highly unfortunate, however this GUID correction needed to happen.

Identifying correct vs. incorrect GUIDs

To make it easier to identify incorrect GUIDs from a correct ones, I'll change the format by removing the Microsoft style curly braces. Curly braces around GUIDs is a Microsoft trend (which is probably why ClampFit and ABFINFO show them) so it makes sense to remove them for this project.

Therefore, if a pyABF GUID has curly braces, it is invalid.

I realize this may require a change in production code if it parses the GUID string, but this seems a reasonable way to alert developers that the GUID has changed.

Generating an incorrect GUID

If you need to test correct GUIDs against the incorrect previously-generated GUIDs, the incorrect GUID can be created from the correct one by copying the last two characters over the two characters preceding them.

def oldIncorrectGUID(GUID):
    """Simulate the old (broken) GUID from the current GUID."""
    print("NEW FORMAT (correct):    " + GUID)
    oldGUID = list(GUID)
    oldGUID[-4:-2] = oldGUID[-2:]
    oldGUID = "{" + "".join(oldGUID) + "}"
    print("OLD FORMAT (incorrect): " + oldGUID)
NEW FORMAT (correct):    307EE462-8A84-41AE-8188-4AB5B73AAAE3
OLD FORMAT (incorrect): {307EE462-8A84-41AE-8188-4AB5B73AE3E3}