Skip to main content

Reader and analysis tools for dserv ESS experiment log files

Project description

essfile

Pure Python reader and analysis tools for dserv ESS experiment log files.

Installation

pip install essfile

This installs essfile with numpy and dgread (for stimulus parameter decoding).

For pandas DataFrame support:

pip install essfile[pandas]

Quick Start

Inspect an ESS file from the command line

essread session.ess
essread session.ess --raw   # show flat datapoint stream

Read in Python

from essfile import ESSFile

f = ESSFile('session.ess')
print(f.identity)    # {'ess': 'hapticvis', 'subject': 'human', ...}
print(f.params)      # {'stim_duration': '30000', ...}
print(f.n_obs)       # 12
print(f.stimdg)      # dict of numpy arrays (stimulus parameters)

Extract trials

from essfile import ESSFile
from essfile.extract.hapticvis import extract_trials

f = ESSFile('session.ess')
trials = extract_trials(f)

print(trials['rt'])       # reaction times
print(trials['correct'])  # 0/1 accuracy

# Convert to DataFrame
import pandas as pd
df = pd.DataFrame(trials)

Low-level access

from essfile import read_dslog, read_ess

# Flat datapoint stream (varname, timestamp, vals columns)
d = read_dslog('session.ess')

# Obs-period oriented with parsed preamble
ess = read_ess('session.ess')

Architecture

The package has three layers:

Layer Function Description
essread read_dslog() Binary parser → flat datapoint stream
essread read_ess() Segments into obs periods, parses preamble
essfile ESSFile Event query API (select, sparse, nested)
extract.* extract_trials() System-specific trial extraction

ESSFile API

The ESSFile class provides methods matching the Tcl df::File API:

f = ESSFile('session.ess')

# Event selection (returns list of bool arrays, one per obs)
mask = f.select_evt('ENDTRIAL')
mask = f.select_evt('STIMULUS', 'ON')

# Sparse extraction (one value per trial, fill=-1 if missing)
valid = np.where(some_condition)[0]
times = f.event_time_sparse(valid, 'RESP')
params = f.event_param_sparse(valid, 'STIMTYPE')
subtypes = f.event_subtype_sparse(valid, 'ENDTRIAL')

# Nested extraction (variable count per trial)
decide_times = f.event_times_nested(valid, 'DECIDE', 'SELECT')

# Name lookups
f.type_id('ENDTRIAL')                    # -> 40
f.subtype_id('ENDTRIAL', 'CORRECT')      # -> 1
f.has_event_type('CHOICES')               # -> True

Writing Extractors

System-specific extractors live in essfile.extract. Each provides an extract_trials(f) function that takes an ESSFile and returns a dict of equal-length arrays (one entry per valid trial).

See essfile/extract/hapticvis.py for a complete example.

File Format

ESS files use the dslog binary format produced by dserv's logger:

  • 16-byte header: magic dslog, version, timestamp
  • Sequence of datapoint records: varname, timestamp, type, data
  • Events encoded with type/subtype/puttype in a 4-byte union
  • Pre-obs preamble contains event name tables, parameters, stimdg

Requirements

  • Python ≥ 3.9
  • numpy
  • dgread (for stimulus parameter decoding)
  • pandas (optional, for DataFrame conversion)

License

MIT

Project details


Download files

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

Source Distribution

essfile-0.1.0.tar.gz (16.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

essfile-0.1.0-py3-none-any.whl (16.9 kB view details)

Uploaded Python 3

File details

Details for the file essfile-0.1.0.tar.gz.

File metadata

  • Download URL: essfile-0.1.0.tar.gz
  • Upload date:
  • Size: 16.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for essfile-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e0fe491a898e4d58c4008964c4b4380576abb24bdf6fde241521ada3ae5b24cf
MD5 cc423a1c10053e7713b46b1f8b47add1
BLAKE2b-256 afa2896d2d5361c69a12d544cb9d0ebaac685324eba83e11a5f9c625f5b6e7d3

See more details on using hashes here.

File details

Details for the file essfile-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: essfile-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 16.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for essfile-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5f0625157e515850894b0105b91efd049d2a08c6cfe2dbab4cdb4c90f690b1fd
MD5 686f9e7e89ea4a9921e23a4d1f8b3333
BLAKE2b-256 d750ef6c55e0645312a01633f62f080f6b273b020eb2d70055aadb7abc261e7f

See more details on using hashes here.

Supported by

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