Tutorial 22: Converting CED Spike2 or Signal files to SCRC waveform data

Data collected with the CED Spike2 software (or Signal) can be read by the SCRC analysis software after converting it to a run file. We now have two different conversion programs for CED data: smr2run can convert .smr files directly, while sptxt2run can convert data exported from Spike2 or Signal as ASCII text files. Why two programs? One reason is historical: conversion from text was much easier to implement, and was done first (in early 2015). We implemented smr2run later (in late 2017) when the need arose to convert a huge collection of .smr files, which would have been difficult to export one by one into text files. The other reason is that there may still be cases where conversion from exported text is preferable, or the only option. If you want to convert only a subset of a file (just a few waveforms, or a limited time range), or if you need to extract data that smr2run is unable to convert from a .smr file, use sptxt2run instead.

Using smr2run

In most cases it will be quicker and easier to convert CED Spike2 .smr data files directly into runfiles using smr2run. The smr2run program will convert all original "Adc" waveforms from the .smr files, as well as processed waveforms stored in the .smr file in the "RealWave" format. It will not convert spike markers or other event timing data, nor will it convert analyzed waveforms stored as alternate versions in the .S2R resource files: e.g., if waveform 6 appears in its original form in Spike2, as well as a waveform 6a which has been processed in Spike2, only the original waveform is converted. If you need to convert waveforms which you can view in Spike2, but which smr2run does not recognize and convert, you will have to export these as text and convert using sptxt2run as described later on in this tutorial.

Once you’ve transferred your .smr files to your Linux analysis system, you can convert them by running the following command: smr2run filename (where filename is the name of one .smr file). It will list the waveforms it finds in the .smr file, and then generate a .frm file using the same filename, for storing the run header information, and several .wnn files, one for each waveform, with nn being the two-digit waveform number. If you want the created run file to have a different name, you can specify it as a second argument, e.g.: smr2run crosDOPA8_0031.smr cd8-31

There is also a batch mode for converting several files at once. In this case, you can’t specify an alternate run name, as all the file name arguments are .smr files to be converted, and the same name will be used for each generated runfile. Batch mode is invoked with the -b command line argument: smr2run -b cros*.smr

There are a few other options that can be specified on the command line, such as -q to make it run more quietly (less output), which might be desirable when converting lots of files, so that error messages or warnings don’t get lost in the noise. See the manual page for smr2run for more details: http://www.scrc.umanitoba.ca/cgi-bin/scrcman2html?smr2run+1.

That’s about all there is to using smr2run. You can quickly convert several directories worth of data in this way, and in general it should proceed without a snag. If you find there are files it cannot convert, or some necessary waveforms are missing, you may want to follow the rest of this tutorial to learn how to export your data as text, and convert the resulting text files using sptxt2run, which is available in our collection of analysis scripts on our web site.

Using sptxt2run: begin by exporting CED data as text

When converting to text, select File/Export As and only export the waveforms as shown below (note that you can also specify the range to be exported if the entire run is not required, and select only a few of the waveforms if you don’t need them all).

There are a few caveats with the Exports, for example, if you have one waveform highlighted (the number on the left hand side of the Spike2 window is in grey highlight) then you would only export that one waveform. Also, when the waveforms are not displayed in numerical order on the Spike2 screen, there may be problems with the conversions. Also, it is best to delete all cursors (but especially the active ones) in order to prevent other glitches with the transfer.

When you are done with the selection, click on OK to proceed. Repeat with each .smr file you need to export and convert. Then transfer the .txt files into a directory on the Linux system (e.g. using FileZilla or some other FTP/SFTP program). Then, in the Linux Terminal window (in same directory where the .txt files are) run the following command: sptxt2run filename

Then you will see the conversion of each waveform in the file, or an error message if there are problems with the conversion.

The .txt files exported from Spike include the original .smr file name in the text file, and the script uses that as the default run file name. Therefore, it does not matter what you called the exported .txt file, the file name will be created from the .smr info. This could be a problem if you have exported several sections of a single, long run in Spike2 and created, for example, run08a.txt, run08b.txt and run08c.txt files, that you want to convert to SCRC run files. All these exported files reference the same .smr source file, so sptxt2run will keep overwriting the same destination run file. The only workaround is to explicitly give the run file name for each conversion, as a second argument to sptxt2run. This can be automated using a shell for loop:

for f in *.txt; do sptxt2run "$f" "${f%.txt}"; done

Note that the quotation marks around the arguments to sptxt2run are needed if any of the file names have spaces. You can omit these but only if there are no spaces in the file names (which is the case with the above example files run08*.txt). These arguments represent the file name, first with the .txt suffix, then without, at each iteration of the for loop, as the loop runs sptxt2run once for each file name. A slight drawback to using the *.txt file names as the run file names is that the SCRC software uses the runfile.txt file as the run description, so for these runs, it will pull the first line of the Spike2 exported files (which is always "INFORMATION") as the run description. You can also remove the .txt files after conversion, if you no longer need them, to avoid the bogus run description.