MEGSIM netMEG //
The NETMEG File Format for MEG and EEG Data
The netMEG file format is designed to be a standard format for MEG and EEG data collected by any sensor system. It contains the signal data, as well as information about sensor location and configuration and archival information. NetMEG files use the netCDF file format standard which has a number of advantages. NetCDF files are self-describing, making it convenient to support variability in the type of data that is stored and to extend the netMEG format as needed, without making older files obsolete. NetCDF supports non-sequential reading of the data, so that just the data that is needed can be read. NetCDF files are portable, and can be read, without translation, on most computers.
NetCDF files store data as arrays. In addition to the arrays, the files store information about the sizes of the arrays, as named dimensions, and also store descriptive information as attributes. In the following sections we describe the arrays, dimensions and attributes that make up a netMEG file. Note that the netMEG file was originally intended for storage of averaged, evoked response MEG data. It has been extended to handle other MEG and EEG data, but some of the variable names reflect its original use. NetMEG files are typically used to store epochs of data which have had signal processing done, and are ready for analysis. However, the format is flexible enough, that it could be used to store raw, continuous data.
Accessing netMEG data
In order to facilitate reading the data into analysis routines, we have provided routines in C and IDL to read netMEG files. The code can be downloaded from the Mind Research Network web site.
MEGAN enables the user to view the contents of a netMEG file and edit the comments.
The following are links to libraries useful for reading netCDF files into MATLAB:
Comments input by the user, plus notes that may have been added by the code which made the netMEG file.
BaselineCorrection_(DC_Offset) [Obsolete: BaselineCorrection or BaselineCorrection (DC Offset)]
The method used for doing a baseline correction of the data, to compensate for a DC shift. Methods currently used are: "Prestim","None", "All Values", "User Selected Interval"
Baseline_Interval_for_Variance_Calc. [Obsolete: Baseline Interval for Variance Calc]
The method used for selecting the data used to calculate the baseline variance.
For averaged data, the method used to average the data, if known. For example, "Neuromag Averaging" if the Neuromag acquisition software averaged the data. If the data was averaged by MEGAN this attribute describes the methods used to reject passes containing artifacts.
For averaged data, the names of files that were averaged together, if known.
Data_Acquisition_Sampling_Interval_(ms) [Obsolete: Data Acquisition Sampling Interval (ms)]
This will differ from the SamplingInterval if the data in the netMEG file was downsampled.
The date on which the data was acquired, if known. The format of this string will vary, because it is read from the input files.
The name of the sensor system used. For example, "Neuromag", "LANL/BTi 7-sensor array", VA/Bti 37 Sensor." MEGAN looks for the "Neuromag" pattern in the MontageName so that it can offer the specialized Neuromag options.
Name of the location of the Sensor System, if known.
This is a string version of the netMEG file version number. It should be the same value as the numerical variable netMEGversionNum.
A string with information about the digital filters, and artifact rejection that were applied to the data, if known. Filters applied by MEGAN are always listed, but if MEGAN is reading previously filtered data, the information may not be available.
This is a list of the channels which were deleted from the data (netMEG version 1.1) or are marked as having a bad status in later netMEG versions.
The name of the main file from which the data was read.
date_of_netMEG_file_creation [Obsolete: date of netMEG file creation]
The date on which this netMEG file was created.
hardware_filter_info [Obsolete: hardware filter info]
A string with information about hardware filters that were used, if available.
hardware_artifact_rejection_info [Obsolete: hardware artifact rejection info]
A string with information about hardware artifact rejection, if available.
Randomization_Range_for_ISI [Obsolete: Randomization Range for ISI]
For evoked response data, the range of the randomized inter-stimulus interval.
These dimensions define the sizes of the arrays described under "Variables"
The number of digitized locations on the subject's head that were recorded.
For Neuromag planar gradiometer data only: the size of the large transform matrix used to convert the data to simulated magnetometer values.
For Neuromag planar gradiometer data only: the size of the small transform matrix used to convert the data to simulated magnetometer values.
The number of Neuromag projector sets in the file, where a projector set is defined by the type of the projector and the channels to which it applies.
Each Neuromag projector set may apply to a different number of channels, and thus have different length projector vectors. This variable defines the length of the longest projector vector.
The total number of vectors in all of the projector sets.
Reference MEG Channels (type MEG_REF) are used for the CTF noise cancellation method. This dimension is used for the variables that contain the coefficients used to weight the reference channel data, and the corresponding channel index of the reference channel.
Waveforms(numStims, numDataPts, numChannels) float
This is the signal for all epochs, from all channels whose data was saved. The channels are described in the chanToSensorMap, ChannelStatus, ChannelTypes and ChannelUnits variables. The number of samples actually stored for each epoch may vary: numDataPts is the maximum number of samples stored for an epoch, while numSamples indicates how many samples were stored for each epoch. The global attribute netCDFfileType indicates whether the stored signal is averaged or unaveraged.
BaselineVariance(numStims, numSensors) ; (float)
The baseline variance for each channel and epoch pair is the square of the standard deviation of the baseline data for that channel and epoch. Baseline data is either the pre-stimulus period (for evoked response data) or a window of data chosen for each epoch of spontaneous data (BaselineData). If there is no baseline data, this variable is set to a default value input by the user. The baseline variance is calculated based on the data as read from the original sensor system file. MEGAN does not recalculate if it changes the noise cancellation state of 4D or CTF data.
chanToSensorMap(numChannels, LengthOfLabelString) ; (char)
This is the name of each channel. The ordering here corresponds to the order of the channel data in the Waveforms variable, and in other variables that contain the "numChannels" dimension.
Different signal processing options may be applied to groups of channels. This variable contains the number of the signal processing option set that was used for each channel. The actual options in each set are listed in the Global Attributes: filtersUsed, and AveragingMethod.
ChannelStatus(numChannels) ; (short)
This variable is used to designate which channels will be used in calculations and visualizations. Good channels have a status of 1, while channels which the user has marked as containing bad data have a status of 0. This variable was introduced in netMEG version 1.2. Version 1.1 files have the data from bad channels deleted. NetMEG files with more recent version numbers which were made from version 1.1 files will have the missing data filled with zeros, and a bad status for the missing channels.
ChannelTypes(numChannels, LengthOfLabelString) ; (char)
ChannelTypes indicates what kind of data each channel contains. MEGAN, and the code to read data for the source localization codes look for "MEG," "MEG_REF," and "EEG" and "EEG_REF" types. Other types often used are "BGD," "STIM," "STI," "EOG," "ECG." MEG_REF refers to reference channels used for noise cancellation in systems like CTFs. These reference channels must be modeled in the forward. BGD refers to data collected by sensors that do not pick up any signal from the brain, (SIS system), and therefore do not need to be modeled in the forward calculation.
ChannelUnits(numChannels, LengthOfLabelString) ; (char)
These strings indicate the units of the data in the Waveforms array. It is assumed that MEG data will be stored as fT, and EEG data as microVolts.
NumElementsInSensor(numSensors) ; (short)
This variable indicates the number of loops in each MEG sensor, allowing for a sensor system with more than one type of MEG sensors.
SensorLocation(numSensors, coords) ; (float)
The meaning of the Sensor Location, which is always in patient coordinates, depends on the type of MEG sensor. For radial gradiometers, it is the location of the loop closest to the head. For magnetometers, it is the location of the magnetometer. For the Neuromag planar gradiometers, it is the midpoint between the two loops. The units are cm.
SensorElementRadius(numSensors, maxSensElements) ; (float)
The radius of each loop of the MEG sensors, in cm. For sensors that are not circular, the radius is the radius of a circle whose area is equivalent to the sensor area.
SensorGain(numSensors) ; (float)
This is the MEG sensor sensitivity. It is here for archival purposes only. The gain has already been applied to data in the Waveforms array.
EEGreferenceLocation(numEEGsensors, coords) ; (float)
The location of the EEG reference sensor corresponding to each pickup sensor, in patient coordinates. Note that unlike the MEG sensor units, these locations are in meters.
EEGpickupRadius(numEEGsensors) ; (float)
The radius of each pickup EEG sensor, in mm.
EEGreferenceRadius(numEEGsensors) ; (float)
The radius of each reference EEG sensor, in mm.
EEGBaselineVariance(numStims, numEEGsensors) ; (float)
The baseline variance for each EEG channel and epoch pair is the square of the standard deviation of the baseline data for that channel and epoch. Baseline data is either the pre-stimulus period (for evoked response data) or a window of data chosen for each epoch of spontaneous data (BaselineData). If there is no baseline data, this variable is set to a default value input by the user.
numSamples(numStims) ; (float)
The number of samples actually stored for each epoch or stimulus condition.
SamplingInterval ; (float)
The elapsed time in ms between each sample in the Waveforms array.
PatientCoords(coords, coords) ; (float)
The locations of the three fiducials (the three locations on the patient's head that are measured for use in reconciling the coordinate systems of different imaging modalities), in cm. These are in the coordinate system used by LANL, CTF and 4D: positive X is in the front half of the head, positive Y is on the patient's left side, positive Z is through the top of the head. If the data acquisition system uses a different coordinate system, the locations are rotated into this system.
CoilToPatientXform(coords, coords) ; (float)
This is the 3X3 transform matrix used to rotate the MEG sensor locations from device coordinates to patient coordinates. These values have not been shifted or rotated.
CoilToPatientXformOrig(coords) ; (float)
The vector used to shift the MEG sensor locations from device coordinates to patient coordinates.
The version number of the netMEG file. This is changed when changes are made to the netMEG file format.
Variables for Averaged Evoked Response Data
LengthOfPrestim(numStims) ; (float)
For evoked response data, the length of the prestimulus period, in ms, that is stored in the Waveforms array.
StimDuration(numStims, LengthOfLabelString) ; (char)
For evoked response data, the duration of the stimulus presentation in ms. This is a character string, to allow for values such as "N/A" or "unknown." It is used for archival purposes only.
For averaged data, this is the number of epochs that were averaged together for each averaged epoch. This may vary because of the number of times each stimulus condition was presented, or because some epochs were rejected because of artifacts. These values are available if MEGAN averaged the data, or in the case that we are reading data averaged by the data acquisition system, if the values exist in the input files.
For averaged, evoked response data, this is the number of times each stimulus condition was presented to the subject. This will not match
NumPassesUsed if some epochs were rejected because of artifacts.
Variables for Spontaneous Data
BaselineData(numStims, numBaselinePts, numChannels) ;(float)
For spontaneous data, the user selects a window of baseline data to pair with each epoch to use to calculate the baseline variance, and to perform a baseline shift. The units correspond to the units in the Waveforms array.
numBaselineSamples(numStims) ; (float)
For spontaneous data, the number of points in each window of baseline data.
epochOffsets(numStims) ; (float)
For unaveraged data, the time in ms after the start of data acquisition at which the first sample of each epoch was taken.
Variables for Neuromag Sensor System Data
largeXform(numSensors, largeXformSize) ; (float)
In order to make contour plots, we simulate magnetometer data as a way to combine the two values that the Neuromag System measures at each location. This transform matrix is used to calculate a minimum norm solution for magnetometer values at largeXformSize locations.
The netMEG file may contain multiple sets of projectors, where a projector set is defined by the type of the projector and the channels to which it applies. All of the projector vectors (from all sets) are contained in the variable, NeuromagProjectorVectors. The variable NeuromagProjectorsSetIdForEachVector indicates to which set each vector belongs. The other projector variables are used to describe each set.
An integer identifier of the projector type corresponding to each set, as defined by the Neuromag software.
NeuromagProjectorsTypeDescription(numNeuromagProjectorSets, LengthOfLabelString); (char)
A description of the projector type corresponding to each set, read from the Neuromag file.
The number of channels to which each projector set applies, and therefore, the length of the projector vectors in each projector set.
The number of projector vectors in each projector set.
For each projector set, the indices of the channels (counting from zero) to which that set applies. Because different projector sets have different numbers of channels, some lists of indices may be padded. The variable NeuromagProjectorsNumChannelsPerProjectorSet indicates the vector length for each projector set.
This variable is used to identify which set each of the vectors in the NeuromagProjectorVectors variable belongs to.
NeuromagProjectorVectors(totalNumNeuromagProjectorVector, maxNeuromagProjectorLength); (float)
The projector vectors for all projector sets. Because different projector sets have different vector lengths, vectors from some sets may be padded. The variable NeuromagProjectorsNumChannelsPerProjectorSet indicates the vector length for each projector set.
Variables for CTF and 4D Neuroimaging Sensor System Data
NoiseBalancedState; scalar, (short)
A value of 0 means no noise cancelling has been done. A value of 3 means that the data is in CTF's 3rd Gradient state or that 4D data has been noise compensated.
For each non-reference MEG channel, the number of Reference Channel, noise coefficient pairs we have.
NoiseCancellingCoefficients( MaximumNumberReferenceMEGChannelsUsed,NumberOfNonReferenceMEGChannels); (double)
For each non-reference MEG channel, the list of coefficients used to weight the Reference Channel signal. MEGAN saves the 3rd Gradient Real coefficients.
ReferenceChannelIndicesForCoefficients( MaximumNumberReferenceMEGChannelsUsed,NumberOfNonReferenceMEGChannels); (short)
For each non-reference MEG channel, the indices of the Reference Channels corresponding to each coefficient.
Variables for the SIS Sensor System Data
headLocationCoilData(3,numHeadLocationCoilPts) ; float
The locations, in LANL subject coordinates, of the coils that are activated to determine the location of the head relative to the sensor system.
SISsensorBaseline(numSensors) ; (int)
The distance of each SIS sensor from the superconducting surface.
Variables from FIF Files
The coil type is present in netMEG files created from files in the fif format. It corresponds to the coil types in the file “coil_def.dat” created by Matti Hamalainen. This file, which is included in the MEGAN distribution, contains recommended integration points for each type of coil.