@@ -479,7 +479,6 @@ static Function NWB_AddDeviceSpecificData(STRUCT NWBAsyncParameters &s, variable
479479
480480 AddModificationTimeEntry ( s. locationID, s. nwbVersion)
481481 NWB_AddDevice ( s)
482- NWB_WriteLabnotebooksAndComments ( s)
483482 NWB_WriteTestpulseData ( s, writeStoredTestPulses)
484483End
485484
@@ -588,12 +587,13 @@ End
588587/// @param overwrite [optional, defaults to false] overwrite any existing NWB file with the same name, only
589588/// used when overrideFilePath is passed
590589/// @param verbose [optional, defaults to true] get diagnostic output to the command line
590+ /// @param recreateEpochs [optional, defaults to false] when set to true, epoch information is recreated if the version of the data in the experiment is older than the latest version
591591///
592592/// @return 0 on success, non-zero on failure
593- Function NWB_ExportAllData ( variable nwbVersion, [ string device, string overrideFullFilePath, string overrideFileTemplate, variable writeStoredTestPulses, variable writeIgorHistory, variable compressionMode, variable keepFileOpen, variable overwrite, variable verbose] )
593+ Function NWB_ExportAllData ( variable nwbVersion, [ string device, string overrideFullFilePath, string overrideFileTemplate, variable writeStoredTestPulses, variable writeIgorHistory, variable compressionMode, variable keepFileOpen, variable overwrite, variable verbose, variable recreateEpochs ] )
594594
595595 string list, name, fileName
596- variable locationID, sweep, createdNewNWBFile, argCheck
596+ variable locationID, sweep, createdNewNWBFile, argCheck, epochVersion
597597 string stimsetList = ""
598598
599599 if ( ParamIsDefault ( keepFileOpen))
@@ -630,6 +630,8 @@ Function NWB_ExportAllData(variable nwbVersion, [string device, string overrideF
630630 verbose = !! verbose
631631 endif
632632
633+ recreateEpochs = ParamIsDefault ( recreateEpochs) ? 0 : !! recreateEpochs
634+
633635 argCheck = ParamIsDefault ( overrideFullFilePath) + ParamIsDefault ( overrideFileTemplate)
634636 ASSERT ( argCheck >= 1 && argCheck <= 2, "Either arg overrideFullFilePath or arg overrideFileTemplate must be given or none (auto-gen)" )
635637
@@ -736,6 +738,13 @@ Function NWB_ExportAllData(variable nwbVersion, [string device, string overrideF
736738 WAVE s. DAQDataWave = TextSweepToWaveRef ( sweepWave)
737739 WAVE s. DAQConfigWave = configWave
738740
741+ if ( recreateEpochs)
742+ epochVersion = GetLastSettingIndep ( s. numericalValues, s. sweep, "Epochs Version" , DATA_ACQUISITION_MODE, defValue = NaN )
743+ if ( IsNaN ( epochVersion) || epochVersion < SWEEP_EPOCH_VERSION)
744+ InsertRecreatedEpochsIntoLBN ( s. numericalValues, s. textualValues, s. device, s. sweep)
745+ endif
746+ endif
747+
739748 NWB_AppendSweepLowLevel ( s)
740749 stimsetList += AB_GetStimsetFromPanel ( device, sweep)
741750
@@ -744,6 +753,8 @@ Function NWB_ExportAllData(variable nwbVersion, [string device, string overrideF
744753 endfor
745754 LOG_AddEntry ( PACKAGE_MIES, "export" , keys = { "size [MiB]" } , values = { num2str ( NWB_GetExportedFileSize ( device))})
746755
756+ NWB_WriteLabnotebooksAndComments ( s)
757+
747758 NWB_AppendStimset ( nwbVersion, s. locationID, stimsetList, compressionMode)
748759
749760 if ( writeIgorHistory)
0 commit comments