WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added data/exampleDataIvium.idf
Binary file not shown.
46 changes: 45 additions & 1 deletion impedance/preprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def readFile(filename, instrument=None):
"""

supported_types = ['gamry', 'autolab', 'parstat', 'zplot', 'versastudio',
'powersuite', 'biologic', 'chinstruments']
'powersuite', 'biologic', 'chinstruments','ivium']

if instrument is not None:
assert instrument in supported_types,\
Expand All @@ -48,8 +48,11 @@ def readFile(filename, instrument=None):
f, Z = readPowerSuite(filename)
elif instrument == 'chinstruments':
f, Z = readCHInstruments(filename)
elif instrument == 'ivium':
f, Z = readIvium(filename)
elif instrument is None:
f, Z = readCSV(filename)


return f, Z

Expand Down Expand Up @@ -390,6 +393,47 @@ def readCHInstruments(filename):

return np.array(f), np.array(Z)

def readIvium(filename):
""" function for reading the .idf file from Ivium

Parameters
----------
filename: string
Filename of .idf file to extract impedance data from

Returns
-------
frequencies : np.ndarray
Array of frequencies
impedance : np.ndarray of complex numbers
Array of complex impedances

"""

with open(filename, 'r', encoding='ISO-8859-2') as input_file:
lines = input_file.readlines()

start_line = 0

for i, line in enumerate(lines):
if 'primary_data' in line:
datapoints_number = int(lines[i+2])
start_line = i+3
end_line = start_line + datapoints_number

f, Z = [], []

if start_line != 0:
raw_data = lines[start_line:end_line]

for line in raw_data:
each = line.split()
f.append(float(each[2]))
Z.append(complex(float(each[0]), float(each[1])))


return np.array(f), np.array(Z)


def readCSV(filename):
""" function for reading plain csv files
Expand Down