File MIES_NeuroDataWithoutBorders.ipf

NWB Functions related to MIES data export into the NeuroDataWithoutBorders format

For writing a full NWB file the following functions are used:

For exporting sweep-by-sweep:

Functions

static variable NWB_GetStartTimeOfSweep(WaveText textualValues, variable sweepNo, wave sweepWave)

Return the starting time, in fractional seconds since Igor Pro epoch in UTC, of the given sweep.

For existing sweeps with HIGH_PREC_SWEEP_START_KEY labnotebook entries we use the sweep wave’s modification time. The sweep wave can be either an DAQDataWave or a Sweep_$num wave. Passing the DAQDataWave is more accurate.

static variable NWB_FirstStartTimeOfAllSweeps()

Return the creation time, in seconds since Igor Pro epoch in UTC, of the oldest sweep wave for all devices.

Return NaN if no sweeps could be found

static string NWB_GetFileNameSuffixDevice(string device)
static string NWB_GetFileNamePrefix()
static std::tuple<variable, variable> NWB_GetFileForExport(variable nwbVersion, string device, string overrideFullFilePath = defaultValue)

Return the HDF5 file identifier referring to an open NWB file for export.

Create one if it does not exist yet.

Parameters:
  • nwbVersion – Set NWB version if new file is created

  • device – device name

  • overrideFullFilePath – [optional] file path for new files to override the internal generation algorithm

Return values:
  • fileID – HDF5 file identifier or NaN on user abort

  • createdNewNWBFile – new NWB file was created (1) or an existing opened (0)

static variable NWB_AddGeneratorString(variable fileID, variable nwbVersion)
static variable NWB_AddSpecifications(variable fileID, variable nwbVersion)
static variable NWB_ReadSessionStartTime(variable fileID)
static variable NWB_AddDevice(NWBAsyncParameters *s)
static string NWB_GenerateDeviceDescription(string device, wave numericalValues, WaveText textualValues)
dfref NWB_ASYNC_Worker(dfref dfr)
variable NWB_ASYNC_Readout(ASYNC_ReadOutStruct *ar)
static variable NWB_WriteLabnoteBooksAndComments(NWBAsyncParameters *s)
static variable NWB_WriteResultsWaves(NWBAsyncParameters *s)
static variable NWB_AddDeviceSpecificData(NWBAsyncParameters *s, variable writeStoredTestPulses)
variable NWB_WriteTestpulseData(NWBAsyncParameters *s, variable writeStoredTestPulses)
static variable NWB_HandleFileOverwrite(string fullFilePath, variable overwrite, variable verbose, string device = defaultValue)

Handle a NWB file handling for overwite flag.

Parameters:
  • fullFilePath – full file path

  • overwrite – flag that indicates if overwrite is enabled or not

  • verbose – flag that indicates if verbose status messgaes are enabled

  • device – [optiona, default auto-determined] device name that uses the given file

Returns:

returns 1 if error occured

variable NWB_ExportAllData(variable nwbVersion, string device = defaultValue, string overrideFullFilePath = defaultValue, string overrideFileTemplate = defaultValue, variable writeStoredTestPulses = defaultValue, variable writeIgorHistory = defaultValue, variable compressionMode = defaultValue, variable keepFileOpen = defaultValue, variable overwrite = defaultValue, variable verbose = defaultValue)

Programmatically export all acquired data from all devices into a NWB file.

Use NWB_ExportWithDialog() for interactive export.

Parameters:
  • nwbVersion – major NWB format version, one of 1 or 2 (aka NWB_VERSION_LATEST)

  • device – [optional, defaults to all devices] when set, only data for the given single device is exported

  • overrideFullFilePath – [optional, defaults to auto-gen] use this full file path instead of an internally derived one, only valid when single device has data

  • overrideFileTemplate – [optional, defaults to auto-gen] use this template file path instead of an internally derived one

  • writeStoredTestPulses – [optional, defaults to false] store the raw test pulse data

  • writeIgorHistory – [optional, defaults to true] store the Igor Pro history and the log file

  • compressionMode – [optional, defaults to chunked compression] One of CompressionMode

  • keepFileOpen – [optional, defaults to false] keep the NWB file open after return, or close it

  • overwrite – [optional, defaults to false] overwrite any existing NWB file with the same name, only used when overrideFilePath is passed

  • verbose – [optional, defaults to true] get diagnostic output to the command line

Returns:

0 on success, non-zero on failure

static wave NWB_GetSweepWave(string device, variable sweep)
variable NWB_ASYNC_FinishWriting(string device)

Wait for ASYNC nwb writing to finish.

Currently wait up to 10min (NWB_ASYNC_WRITING_TIMEOUT * NWB_ASYNC_MAX_ITERATIONS), everything above 5s is considered a bug.

variable NWB_CheckForMissingSweeps(string device, WaveText sweepNames)
static variable NWB_GetExportedFileSize(string device)

Return the file size in MiB of the currently written into NWB file.

This is only approximately correct as the file is open in HDF5 and thus not everything is flushed.

static variable NWB_ExportAllStimsets(variable nwbVersion, string overrideFullFilePath)

Export all stimsets into NWB.

NWB file is closed after the function returns.

variable NWB_ExportWithDialog(variable exportType, variable nwbVersion = defaultValue)

Export all data into NWB using compression.

Ask the file location from the user

Parameters:
  • exportType – Export all data and referenced stimsets (NWB_EXPORT_DATA) or all stimsets (NWB_EXPORT_STIMSETS)

  • nwbVersion – [optional, defaults to latest version] major NWB version

static variable NWB_AppendStoredTestPulses(string device, variable nwbVersion, variable locationID, variable compressionMode)

Write the stored test pulses to the NWB file.

static variable NWB_AppendStimset(variable nwbVersion, variable locationID, string stimsets, variable compressionMode)

Export given stimsets to NWB file.

Parameters:
  • nwbVersion – major NWB version

  • locationID – Identifier of open hdf5 group or file

  • stimsets – Single stimset as string or list of stimsets sparated by ;

  • compressionMode – Type of compression to use, one of CompressionMode

variable NWB_PrepareExport(variable nwbVersion, string device)

Prepare everything for sweep-by-sweep NWB export.

variable NWB_AppendSweepDuringDAQ(string device, wave DAQDataWave, wave DAQConfigWave, variable sweep, variable nwbVersion)
static variable NWB_AppendSweepLowLevel(NWBAsyncParameters *s)
static variable NWB_ClearWriteChannelParams(WriteChannelParams *s)

Clear all entries which are channel specific.

static variable NWB_WriteStimsetCustomWave(variable nwbVersion, variable locationID, wave custom_wave, variable compressionMode)

Save Custom Wave (from stimset) in NWB file.

Parameters:
  • nwbVersion – major NWB version

  • locationID – Open HDF5 group or file identifier

  • custom_wave – Wave reference to the wave that is to be saved

  • compressionMode – [optional, defaults to NO_COMPRESSION] Type of compression to use, one of CompressionMode

static variable NWB_WriteStimsetTemplateWaves(variable nwbVersion, variable locationID, string stimSet, WaveRefWave customWaves, variable compressionMode)
static variable NWB_LoadStimset(variable locationID, string stimset, variable overwrite, variable verbose = defaultValue)

Load specified stimset from Stimset Group.

Parameters:
  • locationID – id of an open hdf5 group containing the stimsets

  • stimset – string of stimset

  • verbose – [optional] set to get more output to the command line

  • overwrite – indicate whether the stored stimsets should be deleted if they exist

Returns:

1 on error

variable NWB_LoadCustomWave(variable locationID, string fullPath, variable overwrite)

Load a custom wave from NWB file.

loads waves that were saved by NWB_WriteStimsetCustomWave

Parameters:
  • locationID – open file or group from nwb file

  • fullPath – full Path in igor notation to custom wave

  • overwrite – indicate whether the stored custom wave should be deleted if it exists

Returns:

1 on error and 0 on success

static string NWB_SuffixExtendedStimsetNamesToStimsetNames(string stimsets)

from a list of extended stimset names with _WP, _WPT or _SegWvType suffix return a boiled down list of unique stimset names without suffix

string NWB_ReadStimSetList(string fullPath)
variable NWB_LoadAllStimsets(variable overwrite = defaultValue, string fileName = defaultValue, variable loadOnlyBuiltins = defaultValue)

Load all stimsets from specified HDF5 file.

Parameters:
  • fileName – [optional, shows a dialog on default] provide full file name/path for loading stimset

  • overwrite – [optional, defaults to false] indicate if the stored stimset should be deleted before the load.

  • loadOnlyBuiltins – [optional, defaults to false] load only builtin stimsets

Returns:

1 on error and 0 on success

variable NWB_LoadStimsets(variable groupID, string stimsets, variable overwrite, string processedStimsets = defaultValue)

Load specified stimsets and their dependencies from NWB file.

see AB_LoadStimsets() for similar structure

Parameters:
  • groupID – Open Stimset Group of HDF5 File. See OpenStimset()

  • stimsets – “;” separated list of all stimsets of the current sweep.

  • processedStimsets – [optional] the list indicates which stimsets were already loaded. on recursion this parameter avoids duplicate circular references.

  • overwrite – indicate whether the stored stimsets should be deleted if they exist

Returns:

1 on error and 0 on success

variable NWB_LoadCustomWaves(variable groupID, string stimsets, variable overwrite)

Load custom waves for specified stimset from Igor experiment file.

see AB_LoadCustomWaves() for similar structure

Returns:

1 on error and 0 on success

static variable NWB_GetTimeSeriesProperties(variable nwbVersion, WaveText numericalKeys, wave numericalValues, WriteChannelParams *p, TimeSeriesProperties *tsp)
static variable NWB_AddSweepDataSets(WaveText numericalKeys, wave numericalValues, variable sweep, string settingsProp, string nwbProp, variable headstage, TimeSeriesProperties *tsp, variable factor = defaultValue, string enabledProp = defaultValue)
variable NWB_LoadLabNoteBook(variable locationID, string notebook, dfref dfr)

function saves contents of specified notebook to data folder

Parameters:
  • locationID – id of nwb file or notebooks folder

  • notebook – name of notebook to be loaded

  • dfr – igor data folder where data should be loaded into

variable NWB_Flush(variable locationID)

Flushes the contents of the NWB file to disc.

static variable NWB_AppendLogFileToString(string path, string *str)
static variable NWB_AppendIgorHistoryAndLogFile(variable nwbVersion, variable locationID)
variable NWB_ConvertToStandardTTLBit(variable value)

Convert between 2^x, this is what we store as channelSuffix for TTL data in NWB, to x what we call TTL bit in MIES.

variable NWB_ConvertTTLBitToChannelSuffix(variable value)

Reverse direction of NWB_ConvertToStandardTTLBit()

variable NWB_CloseAllNWBFiles()

Closes all possibly open export-into-NWB files.

variable NWB_CloseNWBFile(string device)

Close a possibly open export-into-NWB file.

Variables

static const double NWB_ASYNC_WRITING_TIMEOUT = 5
static const double NWB_ASYNC_MAX_ITERATIONS = 120
static const string NWB_OPEN_FILTER = "NWB files (*.nwb):.nwb;"
static const string NWB_FILE_SUFFIX = ".nwb"