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

  • e64b067
  • /
  • processed
  • /
  • subtract_refBDH.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.

  • content
  • directory
content badge
swh:1:cnt:e049e51ded8cda1888323116ab622c1cbfb1f864
directory badge
swh:1:dir:58d640bfd8e188927e6f1b6e8ae0d2fbc1bbee9d

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.

  • content
  • directory
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
subtract_refBDH.m
function sig=subtract_refBDH(time,sig,sig_control,savename,subtract_method)
    
    exptname=strsplit(savename,'\'); exptname=exptname{1};

    %subtract_method=2
    % subraction of sig & control
    % subtract_method='MinResid'  use bestfit model
    % subtract_method='Subtract' just subtract them
    % subtract_method='None' no correction with 405
    % subtract_method= number, manually offset by this value
   
    sig_control=smooth(sig_control,20);
    bestfit = fminsearch(@(x) leastsquareserror_scale(x,sig_control,sig'),1);
    
    corrFig = figure;
    plot(time/60,sig)
    hold on
    
        
    % subtract best fit motion signal
    if strcmp(subtract_method,'MinResid');%subtract_method=='MinResid';
        sig=sig-(sig_control'*bestfit);
        plot(time/60,sig_control'*bestfit,'r');
        savetag = 'dFoFsubMinRes';
    elseif strcmp(subtract_method,'Subtract');%subtract_method=='Subtract';
        sig=sig-sig_control';
        %sig(30000:length(sig))=sig(30000:length(sig) - sig_control(30000:length(sig)'));
        plot(time/60,sig_control','r');
        savetag = 'dFoFsubArith';
    elseif strcmp(subtract_method,'None');%subtract_method=='None';
        sig=sig;
        savetag = 'dFoFsubNone';
    elseif isnumeric(subtract_method);%add this number
        sig=sig+subtract_method;
        savetag = 'dFoF_offset';
    end
    
    % plot signal
    plot(time/60,sig,'k');
    xlabel('Time');
    ylabel('dF/F');
    
    if subtract_method==1;
        title('Least-squares scaling results');
    elseif subtract_method==2;
        title('Simple subtraction results');
    end
    
    legend('Original sig','scaled control','Subtracted sig');
    hold off
    
    savefigDFFcorr = strcat(exptname,'\',exptname,savetag); 
    savefigDFFcorrpng = strcat(exptname,'\',exptname,savetag,'.png')
    savefig(corrFig,savefigDFFcorr);
    saveas(corrFig,savefigDFFcorrpng);

    function f = leastsquareserror_scale(x,series1,series2)
        f = sum((series2-(x.*series1)).^2);
    end

end

back to top

Software Heritage — Copyright (C) 2015–2026, 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