Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for data module version 3 #35

Closed
SomePythonUser opened this issue Oct 4, 2019 · 5 comments · Fixed by #36
Closed

Add support for data module version 3 #35

SomePythonUser opened this issue Oct 4, 2019 · 5 comments · Fixed by #36
Assignees

Comments

@SomePythonUser
Copy link

SomePythonUser commented Oct 4, 2019

Hi!

I'm doing my Masters and will probably continue with my PhD working with EC-Lab quite a bit and I've just about had it with the .mpr file format which requires me to export the data manually every single time.

I stumbled upon this seemingly amazing module and I've been trying to import data using the BioLogic.MPRfile function, but I can't seem to get it to work as I get "ValueError: Unrecognised version for data module: 3" when I run
BioLogic.MPRfile("some_file.mpr")

I have some experience with python but mainly as a tool for data analysis, so my troubles may be a result of my very limited Python knowledge.

I was hoping that you might have an idea as to how I could get this module to work so that I may import .mpr files directly into Python.

(I wasn't really sure how to reach out for help here so I opened an issue as I could find no other way of doing so. I'm sorry if this was an inappropriate way of going about it)

@bcolsen
Copy link
Contributor

bcolsen commented Oct 4, 2019

I'm doing my Masters and will probably continue with my PhD working with EC-Lab quite a bit and I've just about had it with the .mpr file format which requires me to export the data manually every single time.

I completely agree!!!

I can't seem to get it to work as I get "ValueError: Unrecognised version for data module: 3" when I run
BioLogic.MPRfile("some_file.mpr")

Yup this is a bug. Well actually it's not implemented yet. It looks like they made a new version of their undocumented proprietary data format again. So it needs to be reverse engineered again.

@SomePythonUser Since I don't have that version yet. It would be a great help if you could attach a zip file to this issue containing the .mpr and the exported .mpt file so I can see what needs to be changed.

@SomePythonUser
Copy link
Author

SomePythonUser commented Oct 7, 2019

Thanks for your reply.

I'm using EC-Lab V11.30.

I've attached a zip file with a random .mpt file and the corresponding .mpr file below.

sample_files.zip

@bcolsen bcolsen changed the title Help inquiry Add support for data module version 3 Oct 8, 2019
@bcolsen
Copy link
Contributor

bcolsen commented Oct 8, 2019

@SomePythonUser I think I have fixed the problem. It would be great if you could test it as I don't have the new software version.

To test:

It would also be great if you could attach a zip file here with a .mpr and .mpt like before only this time for a very short run so the data file would be short enough to include with galvani for testing.

@bcolsen bcolsen self-assigned this Oct 8, 2019
@SomePythonUser
Copy link
Author

It works really well now. I've tried quite a few different files and I have no issues at all.

I've attached the smallest file, I could find below.
small_sample_files.zip

So, now I just have to stick with this version of EC-Lab, I guess.

Thank you for all your help, and thanks for sharing your work!

@bcolsen
Copy link
Contributor

bcolsen commented Oct 9, 2019

It works really well now. I've tried quite a few different files and I have no issues at all.

That's great, if you use pandas here's some code that you might find usefull. It cleans up the column names so they can be used with the df.column_name access:

def sanitize_labels(label):
    return label.split('/')[0].lower().lstrip('-').translate(dict.fromkeys(map(ord, " ,|()-"),'_')).rstrip('_')

mpr = BioLogic.MPRfile("file_name.mpr")
df = pd.DataFrame(mpr.data)
df.columns = [sanitize_labels(label) for label in df.columns]
df['redox'] = mpr.get_flag('ox/red')

I've attached the smallest file, I could find below.

Looks great, thanks!

So, now I just have to stick with this version of EC-Lab, I guess.

They don't really seem to change the version of the data files that often, so upgrading shouldn't be problem again for a while.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants