Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

Revision 4dbf0ec391b877f21402aed9e8351fe8f7468d14 authored by D019 Rig on 19 December 2019, 23:25:22 UTC, committed by D019 Rig on 19 December 2019, 23:25:22 UTC
Update Calibration
1 parent 4cac1d4
  • Files
  • Changes
  • cb6e09d
  • /
  • Tools
  • /
  • VOR_Analysis
  • /
  • extractSineSegs.m
Raw File Download

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • revision
  • directory
  • content
revision badge
swh:1:rev:4dbf0ec391b877f21402aed9e8351fe8f7468d14
directory badge Iframe embedding
swh:1:dir:f5b842836a02193b4b53d8570e1b32a462cadd75
content badge Iframe embedding
swh:1:cnt:efdc50726261dffdddb29641e2a5a139ed71ab24

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • revision
  • directory
  • content
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
extractSineSegs.m
%{
Maxwell Gagnon 7/30/18

This script finds the 'S' 's' and 'L' key markers from a spike2 recordings
in order to automatically determine the start and stop of SINE segments.

'S' indicates START of a SINEWAVE segment. Either Drum, Chair or Both
's' indicates END of a SINEWAVE segment. Either Drum, Chair or Both
'L' indicates LIGHT ON
'l' indicates LIGHT OFF

NOTE: THIS SCRIPT ONLY WORKS WHEN THE WHOLE EXPERIMENT IS BASED ON SINEWAVES

DO NOT USE FOR EXPERIMENTS WITH STEPS!!
DO NOT USE FOR EXPERIMENTS WITH STIM-ONLY SEGMENTS!!

%}
function [startTimes, endTimes] = extractSineSegs(folder)
%% setup
[~, file] = fileparts(folder);
chanlist = readSpikeFile(fullfile(folder,[file '.smr']),[]);
chanindsAll = [chanlist.number];
chaninds = find(      arrayfun(@(x) any(strcmp(x.title,{'Keyboard'})),chanlist)     );
rawdata = importSpike(fullfile(folder,[file '.smr']),chanindsAll(chaninds));
rawrecData = importSpike(fullfile(folder,[file '.smr']),chanindsAll(4));

%% Sine Experiments
SampleKeys = strcat(rawdata.samplerate(any(rawdata.samplerate == ['S' 's' 'L' 'P'], 2))');
SampleKeyTimes = rawdata.data(any(rawdata.samplerate == ['S' 's' 'L' 'P'], 2))';

% exit if nothing found
if isempty(SampleKeys)
    startTimes = [];
    endTimes = [];
    return
end

% find the correct start/stop patterns
start_Ss_loc = SampleKeyTimes(strfind(SampleKeys, 'Ss'));
end_Ss_loc = SampleKeyTimes(strfind(SampleKeys, 'Ss')+1);

% light on training
start_SLs_loc = SampleKeyTimes(strfind(SampleKeys, 'SLs'));
start_SLs_loc = [start_SLs_loc SampleKeyTimes(strfind(SampleKeys, 'SLs')+1)];
end_SLs_loc = SampleKeyTimes(strfind(SampleKeys, 'SLs')+2); %Normal
%end_SLs_loc = SampleKeyTimes(strfind(SampleKeys, 'SLs')+3); %Dark Resting
end_SLs_loc = [end_SLs_loc SampleKeyTimes(strfind(SampleKeys, 'SLs')+1)];

start_SLL_loc = SampleKeyTimes(strfind(SampleKeys, 'SLL'));
start_SLL_loc = [start_SLL_loc SampleKeyTimes(strfind(SampleKeys, 'SLL')+1)];
end_SLL_loc = SampleKeyTimes(strfind(SampleKeys, 'SLL')+1);
end_SLL_loc = [end_SLL_loc SampleKeyTimes(strfind(SampleKeys, 'SLL')+2)];

% Pulse on Training
start_SPs_loc = SampleKeyTimes(strfind(SampleKeys, 'SPs'));
start_SPs_loc = [start_SPs_loc SampleKeyTimes(strfind(SampleKeys, 'SPs')+1)];
end_SPs_loc = SampleKeyTimes(strfind(SampleKeys, 'SPs')+2);
end_SPs_loc = [end_SPs_loc SampleKeyTimes(strfind(SampleKeys, 'SPs')+1)];

start_SPL_loc = SampleKeyTimes(strfind(SampleKeys, 'SPL'));
start_SPL_loc = [start_SPL_loc SampleKeyTimes(strfind(SampleKeys, 'SPL')+1)];
end_SPL_loc = SampleKeyTimes(strfind(SampleKeys, 'SPL')+2);
end_SPL_loc = [end_SPL_loc SampleKeyTimes(strfind(SampleKeys, 'SPL')+1)];

%% Special Case: The file recording ends before the sine ends (no 's' after 'S')
if SampleKeys(end) == 'S'
    start_special = SampleKeyTimes(end);
    end_special = rawrecData.tend;
    
    print('yes')
else
    start_special = [];
    end_special = [];
end

%% Combine 
startTimes = sort([start_Ss_loc start_SLs_loc start_SLL_loc start_SPs_loc start_SPL_loc start_special])';
endTimes = sort([end_Ss_loc end_SLs_loc end_SLL_loc end_SPs_loc end_SPL_loc end_special])';


%% Take the Experiment start time listed in the excel file, and remove incorrect segments

% remove segments before start time
expmt_start_time = xlsread(fullfile(folder,[file '.xlsx']), 1, 'G2' );
endTimes(startTimes < (expmt_start_time)) = [];
startTimes(startTimes < (expmt_start_time)) = [];

% remove segments after experiment is over
[~, segment_Names, ~] = xlsread(fullfile(folder,[file '.xlsx']), 1, 'A2:A500' );
if length(segment_Names) < length(endTimes)
    endTimes(length(segment_Names)+1:end) = [];
    startTimes(length(segment_Names)+1:end) = [];
end

%% place start and end times into the excel file
if ~isempty(startTimes) && ~isempty(endTimes)
    xlswrite(fullfile(folder,[file '.xlsx']), startTimes, 'Sheet1', 'D2')
    xlswrite(fullfile(folder,[file '.xlsx']), endTimes, 'Sheet1', 'E2')
end
The diff you're trying to view is too large. Only the first 1000 changed files have been loaded.
Showing with 0 additions and 0 deletions (0 / 0 diffs computed)
swh spinner

Computing file changes ...

back to top

Software Heritage — Copyright (C) 2015–2025, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API