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 1def5532c3cefeba955129117e8c23abb7643cf8 authored by Max's Office PC on 20 November 2019, 03:30:51 UTC, committed by Max's Office PC on 20 November 2019, 03:30:51 UTC
Merge branch 'Master' of https://github.com/RaymondLab/Code into Master
2 parent s 08f15ff + 964f3bd
  • Files
  • Changes
  • 4d2e3a8
  • /
  • Projects
  • /
  • Max - CF Project
  • /
  • chanData.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:1def5532c3cefeba955129117e8c23abb7643cf8
directory badge Iframe embedding
swh:1:dir:cac382edddef562293d4732575a6b36b3536f9b6
content badge Iframe embedding
swh:1:cnt:af09a1efb192bfc0f5a69b2f40d90632b0757407

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 ...
chanData.m
classdef chanData
    properties
        excelFile = [];
        expmt_table = [];
        whoseData = [];
        expmtDataFolder = [];
        bFiles = [];
        
    end
    
    methods
        function [self, bPath, expmtRow] = findBehavior(self, name, folder)
            expmtRow = find(strcmp(self.expmt_table.Filename, name));
            bPath = fullfile(folder, name);
            
            % Create new row for new file
            if isempty(expmtRow)
                TempRow = self.expmt_table(find(contains(self.expmt_table.Filename, 'PlaceHolder')), :);
                TempRow.Filename = name;
                self.expmt_table = [self.expmt_table; TempRow];
                expmtRow = find(contains(self.expmt_table.Filename, name));
                disp(name)
            elseif length(expmtRow) > 1
                warning('Possible Duplicate entry')
            end
            
        end
        
        function [self, ephys_exists, ePath] = findEphys(self, bFileName, bFileRow)
            
            if strcmp(self.whoseData, 'Akira')
                eFile = strrep(bFileName, 'unit', 'U');
            elseif strcmp(self.whoseData, 'Jennifer')
                eFile = strrep(bFileName, 'da', 'du');
            else
            end
            
            eFile = strrep(eFile, '.0', '.');

            ephys_loc = find(contains({self.bFiles.name}, eFile));
            
            if any(ephys_loc > 0)
                ephys_exists = 1;
                ePath = fullfile(self.bFiles(ephys_loc).folder, self.bFiles(ephys_loc).name);
                self.expmt_table.EphysFilename{bFileRow} = eFile;
                disp(['     -', eFile])
            else
                ephys_exists = 0;
                ePath = [];
                self.expmt_table.EphysFilename{bFileRow} = 'None';
                self.expmt_table.EphysAlignmentValue(bFileRow) = 0;
                disp('     -No Ephys')
            end
        end
        
        function [self, peakFreqEstimate] = findExpmtFreq(self, datObj, expmtRow)
            maxFreqLoc = [0,0,0,0,0; 0,0,0,0,0];
            for i = 1:8
                
                if length(datObj(i).data) < 1
                    continue
                end
                
                L = length(datObj(i).data);
                Y = fft(datObj(i).data);
                P2 = abs(Y/L);
                P1 = P2(1:floor(L/2+1));
                P1(2:end-1) = 2*P1(2:end-1);
                f = datObj(i).samplerate*(0:(L/2))/L;
                
                if sum(P1 == max(P1)) == 1
                    maxFreqLoc(1, i) = f(P1 == max(P1));
                    maxFreqLoc(2, i) = max(P1);
                end
            end
            
            if strcmp(self.expmt_table.SineStep{expmtRow}, {'Sine'})
                peakFreqEstimate = maxFreqLoc(1,maxFreqLoc(2,:) == max(maxFreqLoc(2,:)));
                peakFreqEstimate = round(peakFreqEstimate * 2)/2;
                self.expmt_table.Freq_Duration(expmtRow) = peakFreqEstimate;
                disp(['     -Freq Est: ', num2str(peakFreqEstimate)]);
            else
                peakFreqEstimate = NaN;
                self.expmt_table.Freq_Duration(expmtRow) = NaN;
                disp(['     -Freq Est: ', 'NaN']);
                
            end
        end
        
        function plotAllChans(~, datObj)
            figure(); clf
            ha = tight_subplot(9,1,[.03 .03],[.03 .03],[.03 .03]);
            for i = 1:8
                
                axes(ha(i));
                
                if isempty(datObj(i).data)
                    title([datObj(i).chanlabel, ' is empty'])
                    continue
                end
                
                samplerate = datObj(i).samplerate;
                timeVec = 0:( 1/samplerate ):( length(datObj(i).data)-1 )/samplerate;
                plot(timeVec, datObj(i).data);
                
                switch i
                    case 1 % h gaze vel
                    case 2 % v eye pos
                    case 3 % h eye pos
                    case 4 % h Target Pos
                    case 5 % h Head vel
                    case 6 % h d Vel (eye2)
                    case 7 % h Target Vel
                    case 8 % ephys?
                end
                
                %title(datObj(i).chanlabel)
                % Only show Tick labels on bottom (Epyhs Channel)
                if i ~= length(ha)-1
                    xticks([]);
                end
            end
        end
                
        function plotPowerSpec(~, datObj)
            figure(99);clf
            za = tight_subplot(9,1,[.03 .03],[.03 .03],[.03 .03]);
            for i = 1:7
                
                L = length(datObj(i).data);
                Y = fft(datObj(i).data);
                P2 = abs(Y/L);
                P1 = P2(1:floor(L/2+1));
                P1(2:end-1) = 2*P1(2:end-1);
                f = datObj(i).samplerate*(0:(L/2))/L;
                
                axes(za(i))
                plot(f, P1, 'k')
                
                % Cosmetics
                xlim([0 11])
                if sum(P1 == max(P1)) == 1
                    vline(f(P1 == max(P1)))
                    title([datObj(i).chanlabel, ':   ', num2str(f(P1 == max(P1)))])
                end
            end
        end
        
        function self = findStimType(self, expmtRow)
            %% Sine or Step?
            
            % Only ask if we don't know
            if contains(self.expmt_table.SineStep{expmtRow}, 'Not Measured') || contains(self.expmt_table.SineStep{expmtRow}, 'Unknown')
                
                % Input for Sine/Step Information
                answer = questdlg('Sine or Step?', ...
                    'Dessert Menu', ...
                    'Sine','Step','Unknown', 'Unknown');
                
                % Save Sine/Step information
                if contains(answer, 'Sine')
                    self.expmt_table.SineStep{expmtRow} = 'Sine';
                elseif contains(answer, 'Step')
                    self.expmt_table.SineStep{expmtRow} = 'Step';
                elseif contains(answer, 'Unknown')
                    self.expmt_table.SineStep{expmtRow} = 'Unknown';
                end
            end
            disp(['     -', self.expmt_table.SineStep{expmtRow}]);
            
            %% What kind Stim?
            
            % Sine
            if contains(self.expmt_table.SineStep{expmtRow}, 'Sine')
                
                % Only ask if we don't know
                if contains(self.expmt_table.StimType{expmtRow}, 'Unknown') || contains(self.expmt_table.StimType{expmtRow}, 'Not Measured')
                    
                    % Input for Sine/Step Information
                    answer = questdlg('Expmt Type?', ...
                        'Dessert Menu', ...
                        'OKR','VORD', 'Unknown', 'Unknown');
                    if contains(answer, 'Unknown')
                        answer = questdlg('Exmpt Type?', ...
                            'Dessert Menu', ...
                            'x0', 'x2', 'Unknown', 'Unknown');
                    end

                    % Save StimType information
                    self.expmt_table.StimType{expmtRow} = answer;
                    disp(['     -Stim Type: ', answer]);
                end
                    
            end
            

        end
        
        function self = findAmpPhase(self, datObj, peakFreqEstimate, expmtRow)
            
            % Make sure you have a peakFreqEstimate value
            if isnan(peakFreqEstimate)
                return
            end
            
            % Generate Fit
            for i = 1:8
                if isempty(datObj(i).data)
                    continue
                end
                
                segLength = length(datObj(i).data);
                segTime = (1:segLength)/datObj(i).samplerate;
                freq = peakFreqEstimate;
                y1 = sin(2*pi*freq*segTime(:));
                y2 = cos(2*pi*freq*segTime(:));
                constant = ones(segLength,1);
                vars = [y1 y2 constant];
                
                b = regress(datObj(i).data, vars);
                amp = sqrt(b(1)^2+b(2)^2);
                phase = rad2deg(atan2(b(2), b(1)));
                
                switch datObj(i).chanlabel
                    case 'Horz Target Vel'
                        self.expmt_table.rawTargetVelAmp(expmtRow) = amp;
                        self.expmt_table.rawTargetVelPhase(expmtRow) = phase;
                        disp(['     -Target Amp: ',  num2str(amp)]);
                    case 'Horz Head Vel'
                        self.expmt_table.rawHeadVelAmp(expmtRow) = amp;
                        self.expmt_table.rawHeadVelPhase(expmtRow) = phase;
                        disp(['     -Head Amp: ',  num2str(amp)]);
                    case 'Horz Gaze Vel'
                        self.expmt_table.rawGazeVelAmp(expmtRow) = amp;
                        self.expmt_table.rawGazeVelPhase(expmtRow) = phase;
                        disp(['     -Gaze Amp: ', num2str(amp)]);
                end
            end
        end
        
        function self = findCSInfo(self, datObj, expmtRow)
            if isempty(datObj(contains({datObj.chanlabel}, 'cs')).data)
                self.expmt_table.CSPresent(expmtRow) = 0;
                self.expmt_table.CSSorted(expmtRow) = 0;
            end
        end
        
        function self = findEphysAllignment(self, datObj, expmtRow, shiftConfidence)
            % Add Alignment Value
            ephys_shift = datObj(contains({datObj.chanlabel}, 'Ephys')).tstart;
            if ~(self.expmt_table.EphysAlignmentValue(expmtRow) == ephys_shift) && (shiftConfidence > 30)
                self.expmt_table.EphysAlignmentValue(expmtRow) = ephys_shift;
                disp(['     -Ephys Shift: ', num2str(ephys_shift)]);
            else
                self.expmt_table.EphysAlignmentValue(expmtRow) = NaN;
                disp('     -Ephys Shift: NaN');
            end
        end
        
        function plot2(~, datObj)
            figure(98);clf
            pa = tight_subplot(2,1,[.03 .03],[.03 .03],[.03 .03]);
            
            axes(pa(1))
            % Target Vel
            samplerate = datObj(7).samplerate;
            timeVec = 0:( 1/samplerate ):( length(datObj(7).data)-1 )/samplerate;
            plot(timeVec, datObj(7).data, 'r'); hold on
            
            % Head Vel
            samplerate = datObj(5).samplerate;
            timeVec = 0:( 1/samplerate ):( length(datObj(5).data)-1 )/samplerate;
            plot(timeVec, datObj(5).data, 'b'); 
            
            legend({'Target', 'Head'})
            % Gaze Vel
            %samplerate = datObj(1).samplerate;
            %timeVec = 0:( 1/samplerate ):( length(datObj(1).data)-1 )/samplerate;
            %plot(timeVec, datObj(1).data, 'k');
            
            ylim([-50 50])
            xlim([0 5])
            title('Vel')
            
            axes(pa(2))
            % target Pos
            samplerate = datObj(4).samplerate;
            timeVec = 0:( 1/samplerate ):( length(datObj(4).data)-1 )/samplerate;
            plot(timeVec, datObj(4).data, 'r'); hold on
            
            % eye Pos
            samplerate = datObj(3).samplerate;
            timeVec = 0:( 1/samplerate ):( length(datObj(3).data)-1 )/samplerate;
            plot(timeVec, datObj(3).data, 'k'); hold on
            ylim([-30 30])
            xlim([0 5])
            title('Pos')
            
            
            
            
        end
        
        function plotEphys(self, datObj)
            ephysPlot = tight_subplot(1,1,[.03 .03],[.03 .03],[.03 .03]);
            ephysChan = datObj(contains({datObj.chanlabel}, 'Ephys'));
            
            samplerate = ephysChan.samplerate;
            timeVec = 0:( 1/samplerate ):( length(ephysChan.data)-1 )/samplerate;
            plot(timeVec, ephysChan.data);
            
        end
        
        
    end
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