Hey @mdmurbach -- this package is awesome. Great work to you and the other contributors.
In addition to MPT files (which are manually exported from Bio-logic's ECLab), it would be awesome to be able to read in the binary MPR files saved by ECLab as well. This functionality would allow users to avoid ECLab altogether for postprocessing.
Fortunately, the galvani package has MPR reading functionality in its BioLogic.py file. The PyPI release lags the repo, so I simply downloaded BioLogic.py and placed it in the same directory.
I have a template function here that works, but this function could probably use more input validation.
from BioLogic import MPRfile # local version; use galvani package if it's updated
def read_mpr(filename):
"""
Function for reading the .mpr file from Biologic
EC-lab software
Parameters
----------
filename: string
Filename of .mpr file to extract impedance data from
Returns
-------
frequencies : np.ndarray
Array of frequencies
impedance : np.ndarray of complex numbers
Array of complex impedances
"""
file = MPRfile(filename) # MPRfile class located in BioLogic.py from galvani package
df = pd.DataFrame(file.data) # MPR file
# Convert to numpy
f = df['freq/Hz'].to_numpy()
Z = df['Re(Z)/Ohm'].to_numpy() - 1j*df['-Im(Z)/Ohm'].to_numpy()
# Convert from complex64 to complex
Z = Z.astype(complex)
return f, Z
Hey @mdmurbach -- this package is awesome. Great work to you and the other contributors.
In addition to MPT files (which are manually exported from Bio-logic's ECLab), it would be awesome to be able to read in the binary MPR files saved by ECLab as well. This functionality would allow users to avoid ECLab altogether for postprocessing.
Fortunately, the galvani package has MPR reading functionality in its BioLogic.py file. The PyPI release lags the repo, so I simply downloaded BioLogic.py and placed it in the same directory.
Here is a sample file: test.mpr.zip
I have a template function here that works, but this function could probably use more input validation.