NSpike Data Conversion
The downsampling and conversion process mainly uses the MATLAB function called NTools_Process written by Matthew Davidson. The function can be used on the Nspike-server (and is version regulated). Each lab should have a user name and password. If not, please contact Amy Trongnetrpunya (firstname.lastname@example.org). The server syncs with Nspike every night at midnight, so Nspike data should be available on the server by the next morning, depending of course on file size, Nspike usage, and time spent online. The following is a step-by-step protocol for data downsampling and conversion.
*WORK IN PROGRESS* – pictures & editing
- On Nspike server, In MATLAB go to subject folder and then to correct folder of task (in the current directory)
- In MATLAB prompt type
(ignore numbers in fields)
- Use the first button (Display .dat file info) to double-check data file parameters and size.
Select .dat file: NY*_FWIO_*.low.nspike.dat
- Use the second button (Convert) to downsample.
Data type: float32
Select .dat file: NY*_FWIO_*.low.nspike.dat
Save file as: NY*_FWIO_*.500Hz_flt32.nspike.dat (when saving file, just change “low” to “500Hz_flt32)
This process will take several minutes. You will then be prompted to select a .dio.txt file to convert. go ahead and do it (this does not take long) DON’T DO IT, IT’S A TRAP!
THIS DOWNSAMPLED DIO.TXT FILE IS NOT TO BE USED WHEN EPOCHING DATA! USE THE ORIGINAL DIO.TXT WHICH IS SAMPLED AT 30kHZ.
If the DIO file is manually made, e.g. from the COMEDI file, timestamps must be at 30 kHz as well. For example, if trial #1 is 23.456 seconds into the recording, the timestamp must be 23.4567*30000=703680.
Conversion to Epoched TimeSurfer Data Structure
Before you epoch the data, check that the triggers in the dio and the experiment file match up.
View the triggers sent in the dio file by typing the following in the command window:
>> load (‘NY313_110523_FEM-exp.mat’) (structure array in Matlab, defines conditions in experiment. click on event to see the different options. Source port shows channel it was sent to)
>> ntools_dio_view(‘NY313_110523_FEM.dio.txt’) (interprets txt file:)
– Text file can be viewed in wordpad outside of Matlab. Text file will have timestamp and binary representation of trigger (ex – happy new/old, sad new/old, neutral new/old faces)
This displays the time stamp and the trigger sent. The summary at the end displays how many of each trigger was sent.
Load the experiment file and check that the events in the experiment file match the triggers set. You will get an error if the experiment file contains a trigger that the dio file does not. Save the experiment file if you make any changes.
– Check that it has the correct number of events: experiment.events
– Check that for each event start_offset=-500 and stop_offset=1000 (this is the length that the epochs will be)
To generate the epochs:
- In NTools_Process, use the fourth button to generate the epoch data structure
Select downsampled .dat file: NY*_FWIO_*.500Hz_flt32.nspike.dat
Select .dio.txt file: NY*_FWIO_*.dio.txt << the .dio file you created at the end of step 3 above (USE ORIGINAL dio.txt FILE, NOT 500Hz dio file)
Select .mat file: NY*_FWIO_*-exp.mat
Cancel prompt for coordinate files
Save file as: NY*_FWIO_*.500Hz.nspike.epoch_data.mat (save name should come up automatically)
This process will take several minutes.
??? Error using ==> ntools_gen_epoch_data>set_epochs at 112
No trials/epochs found in recording. Use ntools_gen_cont_data for continuous data.
– check that the triggers in the exp.mat file match the triggers in the dio file (code and number)
if they don’t match up, columns can be deleted from experiment.event)
Conversion to FieldTrip
- Use the timesurfer function ts_data2fieldtrip (available on nspike server).
Upload files to UCSD
- Open ProgramsNSpike iEEG protocol -> SSH Secure Shell -> Secure File Transfer Client (this should be done in the NSpike server window)
- Click File -> Quick Connect
Host Name: ip61.ucsd.edu
User Name: ccarlson
- On Remote Server go to folder: /home/halgdev/incoming/iEEG_NYU/NY*, and create a folder for the task. (current incoming directory: /space/mdeh1/10/halgdev/incoming/iEEG_NYU)
- On Local computer select the files you created, the .mat, comedi, glove, log, dio, patient_def files and upload them. (Operation -> Upload) or drag
These files need to be uploaded for every patient: