{"action":"created","issue":{"url":"https://api.github.com/repos/RTXI/rtxi/issues/108","repository_url":"https://api.github.com/repos/RTXI/rtxi","labels_url":"https://api.github.com/repos/RTXI/rtxi/issues/108/labels{/name}","comments_url":"https://api.github.com/repos/RTXI/rtxi/issues/108/comments","events_url":"https://api.github.com/repos/RTXI/rtxi/issues/108/events","html_url":"https://github.com/RTXI/rtxi/issues/108","id":164630970,"number":108,"title":"Hdf5 to python","user":{"login":"rythorpe","id":20212206,"avatar_url":"https://avatars.githubusercontent.com/u/20212206?v=3","gravatar_id":"","url":"https://api.github.com/users/rythorpe","html_url":"https://github.com/rythorpe","followers_url":"https://api.github.com/users/rythorpe/followers","following_url":"https://api.github.com/users/rythorpe/following{/other_user}","gists_url":"https://api.github.com/users/rythorpe/gists{/gist_id}","starred_url":"https://api.github.com/users/rythorpe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rythorpe/subscriptions","organizations_url":"https://api.github.com/users/rythorpe/orgs","repos_url":"https://api.github.com/users/rythorpe/repos","events_url":"https://api.github.com/users/rythorpe/events{/privacy}","received_events_url":"https://api.github.com/users/rythorpe/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-07-08T22:53:10Z","updated_at":"2016-07-08T23:03:59Z","closed_at":null,"body":"We'd like to use python for our data analysis, but can't read the HDF5 version supported by RTXI via pytables and pandas. Could RTXI be updated to output the most recent version of HDF5?\r\n\r\nHere is our error report from python:\r\n\r\nValueError: PyTables [3.2.3.1] no longer supports opening multiple files\r\neven in read-only mode on this HDF5 version [1.8.4]. You can accept this\r\nand not open the same file multiple times at once,\r\nupgrade the HDF5 version, or downgrade to PyTables 3.0.0 which allows\r\nfiles to be opened multiple times at once"},"comment":{"url":"https://api.github.com/repos/RTXI/rtxi/issues/comments/231492856","html_url":"https://github.com/RTXI/rtxi/issues/108#issuecomment-231492856","issue_url":"https://api.github.com/repos/RTXI/rtxi/issues/108","id":231492856,"user":{"login":"anselg","id":6200846,"avatar_url":"https://avatars.githubusercontent.com/u/6200846?v=3","gravatar_id":"","url":"https://api.github.com/users/anselg","html_url":"https://github.com/anselg","followers_url":"https://api.github.com/users/anselg/followers","following_url":"https://api.github.com/users/anselg/following{/other_user}","gists_url":"https://api.github.com/users/anselg/gists{/gist_id}","starred_url":"https://api.github.com/users/anselg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/anselg/subscriptions","organizations_url":"https://api.github.com/users/anselg/orgs","repos_url":"https://api.github.com/users/anselg/repos","events_url":"https://api.github.com/users/anselg/events{/privacy}","received_events_url":"https://api.github.com/users/anselg/received_events","type":"User","site_admin":false},"created_at":"2016-07-08T23:03:59Z","updated_at":"2016-07-08T23:03:59Z","body":"Here's a quick snippet that will read an trial from an recorded hdf file as a pandas dataframe and plot the timerseries. (copied from the getTrial.py function in my handy-scripts repository; not tested much): \r\n\r\n```\r\n#! /bin/python\r\n\r\n# Requires h5py, seaborn\r\n\r\nimport h5py as h5\r\nimport numpy as np\r\nimport pandas as pd\r\nimport seaborn as sb\r\nfrom matplotlib.backends.backend_pdf import PdfPages\r\n\r\nfilename = \"test.h5\"\r\nplotname = \"test.pdf\"\r\ntrialnum = 1\r\n\r\n\r\ndef getNumTrials(f):\r\n    ntrials = len(f[\"/\"])\r\n    print(\"# of Trials:\\t\", ntrials)\r\n    return ntrials\r\n\r\ndef getTrial(f, n):\r\n    trialname = \"/Trial\" + str(n)\r\n    return f[trialname]\r\n\r\ndef getPeriod(f, n):\r\n    return f[\"/Trial\" + str(n) + \"/Period (ns)\"].value\r\n\r\ndef getDownsamplingRate(f, n):\r\n    return f[\"/Trial\" + str(n) + \"/Downsampling Rate\"].value\r\n\r\ndef getTrialLength(f, n):\r\n    return f[\"/Trial\" + str(n) + \"/Trial Length (ns)\"].value\r\n\r\ndef getChannelFrame(f, n):\r\n    meta = [ item for item in f[\"/Trial\" + str(n) + \"/Synchronous Data\"] ]\r\n    headers = [ item.split(\" : \")[1] for item in meta[0:3] ]\r\n    data = f[\"/Trial\" + str(n) + \"/Synchronous Data/\" + str(meta[len(meta)-1])]\r\n    frame = pd.DataFrame(data=np.vstack(data), columns=headers)\r\n    frame[\"Time (ms)\"] = range(0, len(frame))\r\n    return frame\r\n\r\nhdf = h5.File(filename, 'r')\r\n\r\ngetNumTrials(hdf)\r\n\r\nperiod = getPeriod(hdf, trialnum) # in ns\r\ndownsampling = getDownsamplingRate(hdf, trialnum)\r\nlength = getTrialLength(hdf, trialnum) # in ns\r\nframe = getChannelFrame(hdf, trialnum)\r\nmeltyframe = pd.melt(frame, \"Time (ms)\")\r\n\r\nhdf.close()\r\n\r\n# gennerate plots\r\nwith PdfPages(plotname) as pdf:\r\n#    p = sb.lmplot(x=\"Time (ms)\", y=\"value\", hue=\"variable\", data=meltyframe, size=5, aspect=2, fit_reg=False)\r\n#    pdf.savefig(p.fig)\r\n\r\n    for field in meltyframe['variable'].unique():\r\n        p = sb.lmplot(x=\"Time (ms)\", y=field, aspect=2, size=5, data=frame, fit_reg=False)\r\n        pdf.savefig(p.fig)\r\n\r\n```"}}
{"actor":{"display_login":"anselg"}}