Skip to main content

Python wrapper for MED format

Project description

DHN-MED-Py

Python wrapper for MED format, GPL license 3.0. Commercial exceptions to GPL open source requirements may be negotiated with Dark Horse Neuro, Inc.

Multiscale Electrophysiology Data Format (MED) is an open source data format developed to manage big data in electrophysiology and facilitate data sharing.

The MED format is maintained by MEDFormat.org.

Installation

To install please use:

pip install dhn-med-py

Numpy is a required dependency.

Wrapper features

  • Opens all MED format data for reading directly into python environment.
  • Fully open-source (GPL license 3.0) for both C library code and python wrapper.
  • Samples are returned in NumPy arrays for easy and efficient processing.
  • Channel and session metadata are returned in python dictionaries.
  • Threaded file opening and channel reading for optimal performance.
  • Optional matrix (2D NumPy array) output for efficient processing/visualization.
  • Support for major platforms (MacOS, Linux, Windows).
  • Supported format in the Neo project.

Sample Script

#!/usr/bin/env python3

import dhn_med_py

from dhn_med_py import MedSession

# open session
sess = MedSession("/Users/JohnDoe/Desktop/MED-test/RawData.medd", "password")

print("First channel name:", sess.session_info['channels'][0]['metadata']['channel_name'])
sampling_rate = sess.session_info['channels'][0]['metadata']['sampling_frequency']
print("Sampling rate of first channel:", sampling_rate)

# read first minute of data, in 1 second chunks
for y in range(0, 60):
    sess.read_by_index(sampling_rate * y, sampling_rate * (y+1))
    print(sess.data['channels'][0]['data'])

# read first minute of data, in 1 second chunks
# negative time means relative to beginning of session
for y in range(0, 60):
    sess.read_by_time(y * -1000000, (y+1) * -1000000)
    print(sess.data['channels'][0]['data'])

# read matrix of first 1 minute of data.
# Return 5000 samples of data per channel (matrix has 5000 columns)
# antialiasing will be applied when downsampling (default filter setting is 'antialias')
sess.get_matrix_by_time(0, -60 * 1000000, sample_count=5000)

# print number of samples in each channel of the resulting matrix
print(sess.matrix['sample_count'])

# print the resulting matrix samples (2D Numpy array)
print (sess.matrix['samples'])

# read matrix of first 1 minute of data
# Return a sampling frequency of 3000 Hz.
sess.get_matrix_by_time(0, -60 * 1000000, 3000)

# print resulting matrix
print (sess.matrix['samples'])

# Read entire dataset, with output sampling set to 1000 Hz
sess.get_matrix_by_time('start', 'end', 1000)

# Read first 25000 samples, using the channel "5k_0001" as the reference channel
# This means the first 5 seconds of the session (for all channels) will be read.
# The default output number of samples corresponds to the highest channel
# sampling frequency.
sess.set_reference_channel("5k_0001")
sess.get_matrix_by_index(0, 25000)

# helper function to set detrending (baseline correction) for future matrix calls
sess.set_detrend(True)

# helper function to set trace_ranges.  Matrix calls will return these
# as "minima" and "maxima" in the matrix result.
sess.set_trace_ranges(True)

# helper function to turn off filtering for future matrix calls
sess.set_filter("none")

# free session
del sess

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

dhn_med_py-1.1.3-cp312-cp312-win_amd64.whl (204.4 kB view details)

Uploaded CPython 3.12 Windows x86-64

dhn_med_py-1.1.3-cp311-cp311-win_amd64.whl (204.3 kB view details)

Uploaded CPython 3.11 Windows x86-64

dhn_med_py-1.1.3-cp310-cp310-win_amd64.whl (204.3 kB view details)

Uploaded CPython 3.10 Windows x86-64

dhn_med_py-1.1.3-cp39-cp39-win_amd64.whl (241.0 kB view details)

Uploaded CPython 3.9 Windows x86-64

dhn_med_py-1.1.3-cp38-cp38-win_amd64.whl (241.0 kB view details)

Uploaded CPython 3.8 Windows x86-64

File details

Details for the file dhn_med_py-1.1.3-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for dhn_med_py-1.1.3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 be1f6899223dbfd695bbf23dd0fdbee10ef8c19f51aae4bfcd24615e8f015713
MD5 29f14133f989f86ff1d48a9c41f6dacd
BLAKE2b-256 bbe593d56205aedceb71d751e3794afe9b562f684fb9a4079f6b5b065c05a04d

See more details on using hashes here.

File details

Details for the file dhn_med_py-1.1.3-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for dhn_med_py-1.1.3-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 7a0a6af5dbe4f50d11d7782a991a6a882de71446590b48bf6901000a3d6c702f
MD5 08653233a563d2d72fffa0e23c5766c9
BLAKE2b-256 ba77f9d5f677b6ddf1f17adb7bc95da166fe0e53b5182bc9baa15c90c6273f2a

See more details on using hashes here.

File details

Details for the file dhn_med_py-1.1.3-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for dhn_med_py-1.1.3-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 cee2edd3de1863d8076561a7eca687bc978792b91d5ba11f0641aab39539f068
MD5 39ab510b53bc57b93560b06d678f4af6
BLAKE2b-256 f5ae8a48a29443b16d97388462661d2bb4bb9d2151f7407c9c2f148a9a03011a

See more details on using hashes here.

File details

Details for the file dhn_med_py-1.1.3-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: dhn_med_py-1.1.3-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 241.0 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for dhn_med_py-1.1.3-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 c9ddcb692a83bd03fcea2f8a9afb5ba27a95b692013a91f9720b3ac7ed6acb9c
MD5 32071c7fffc719dd5dc196bfeb901182
BLAKE2b-256 dd3af8506a59a9db918183114848f6ca6f5d9a537632631073fb0d44d143a3c9

See more details on using hashes here.

File details

Details for the file dhn_med_py-1.1.3-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: dhn_med_py-1.1.3-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 241.0 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for dhn_med_py-1.1.3-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 98c37ee39d784c9a3be2debd5770a4f885e1e2062d15f6ed3c82ce0d117fc89a
MD5 06c587db4a15e2e914a725667de53c27
BLAKE2b-256 fd505775118aba3b437e61b6b15ab6165697d70aada1dbd4695122789fc0bd04

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page