Converts Mayo Clinic MEF (Multiscale Electrophysiology Format) files to NWB (Neurodata Without Borders) format.
This processor reads MEF 3.0 files via a Java streaming library and produces a single NWB 2.x file containing all channels as an ElectricalSeries. The output is compatible with downstream analysis pipelines such as processor-post-timeseries.
- Memory-efficient streaming: processes large recordings without loading entire datasets into RAM
- Gap detection: automatically uses explicit timestamps when discontinuities are present
- Multi-channel support: aggregates all channels into a single NWB file with proper electrode metadata
- Docker and Docker Compose
- MEF 3.0 input files
processor-mef-timeseries/
├── processor/
│ ├── main.py # Entry point
│ ├── config.py # Environment configuration
│ ├── mef_streamer.py # Java subprocess streaming
│ ├── multi_channel_reader.py # Channel data access
│ └── nwb_writer.py # NWB file generation
├── data/
│ ├── input/ # Place MEF files here
│ └── output/ # NWB output written here
├── Dockerfile
├── docker-compose.yml
├── dev.env
└── Makefile
-
Create the input directory:
mkdir -p data/input
-
Copy your MEF session folder into
data/input/. The structure should look like:data/input/ └── your_session.mefd/ ├── your_session.timd/ │ ├── channel1.tdat/ │ ├── channel2.tdat/ │ └── ... └── ... -
Create the output directory:
mkdir -p data/output
make runThis will:
- Build the Docker image (includes Java MEF streamer)
- Mount
data/inputanddata/outputvolumes - Run the conversion
- Output the NWB file to
data/output/output.nwb
docker-compose build
docker-compose upmake cleanEnvironment variables can be set in dev.env:
| Variable | Default | Description |
|---|---|---|
INPUT_DIR |
/data/input |
Directory containing MEF files |
OUTPUT_DIR |
/data/output |
Directory for NWB output |
OUTPUT_FILENAME |
output.nwb |
Name of the output file |
STREAM_FROM_JAR |
true |
Whether to run the Java MEF streamer |
JAVA_CMD |
(see dev.env) | Command to launch MEF streamer |
The converter produces an NWB 2.x file with:
- Device:
MEFDevice - ElectrodeGroup:
MEFElectrodescontaining all channels - ElectricalSeries: Sample data with either:
- Constant
rate(for continuous recordings) - Explicit
timestamps(when gaps are detected)
- Constant
Each electrode includes a channel_name column preserving the original MEF channel names.
- Streaming: The Java
mefstreamer.jarreads MEF files and emits a binary frame protocol to stdout - Staging: Python receives frames and writes intermediate
.bin(samples) and.json(metadata) files - Reading:
MultiChannelReaderloads metadata and provides memory-mapped access to sample data - Writing:
NWBWriterconstructs the NWB file using chunked iteration to minimize memory usage
The processor is designed for large files, but if you encounter OOM errors:
- Ensure Docker has sufficient memory allocated (recommended: 8GB+)
- Check that no other memory-intensive processes are running
- Verify MEF files are in the correct location (
data/input/) - Check that the session folder has the
.mefdextension - Ensure the MEF files are valid MEF 3.0 format
- Check Docker logs for Java stderr output
- Verify the MEF files are not corrupted
- Try with a smaller test dataset first
See LICENSE file for details.