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

https://github.com/ViCCo-Group/THINGS-data
02 March 2023, 06:01:16 UTC
  • Code
  • Branches (2)
  • Releases (0)
  • Visits
    • Branches
    • Releases
    • HEAD
    • refs/heads/main
    • refs/heads/oli
    No releases to show
  • 103c132
  • /
  • MEG
  • /
  • step3h_validation_rsa_behaviour.m
Raw File Download
Take a new snapshot of a software origin

If the archived software origin currently browsed is not synchronized with its upstream version (for instance when new commits have been issued), you can explicitly request Software Heritage to take a new snapshot of it.

Use the form below to proceed. Once a request has been submitted and accepted, it will be processed as soon as possible. You can then check its processing state by visiting this dedicated page.
swh spinner

Processing "take a new snapshot" request ...

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
  • revision
  • snapshot
origin badgecontent badge
swh:1:cnt:d8184e126d2ea5a71046d8a560084c3f65356f5c
origin badgedirectory badge
swh:1:dir:000e91241105269711aba9dceee5d5fb752db093
origin badgerevision badge
swh:1:rev:2d95c15d3a2cc5984ffd4a9a2c4ad3496847ca9d
origin badgesnapshot badge
swh:1:snp:4c1e0fab18d6e2d8038137bab93d0cb9721ba358

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
  • revision
  • snapshot
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 ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Tip revision: 2d95c15d3a2cc5984ffd4a9a2c4ad3496847ca9d authored by Oliver Contier on 28 February 2023, 15:15:53 UTC
fixed howtocite
Tip revision: 2d95c15
step3h_validation_rsa_behaviour.m
function step3h_validation_rsa_behaviour(bids_dir, toolbox_dir, varargin)
    %% RSA between the behavioural similarity matrix and the MEG pairwise decoding accuracies
    % 
    %
    % @ Lina Teichmann, 2022
    %
    % Usage:
    % step3h_validation_rsa_behaviour(bids_dir, ...)
    %
    % Inputs:
    %   bids_dir            path to the bids root folder 
    %   toolbox_dir         path to toolbox folder containtining CoSMoMVPA

    % Returns:
    %   _                   Figure in BIDS/derivatives folder


    %% folders
    res_dir         = [bids_dir '/derivatives/output/']; 
    figdir          = [bids_dir '/derivatives/figures/'];
    
    addpath(genpath([toolbox_dir '/CoSMoMVPA']))
    %% parameters    
    n_participants  = 4;

    % plotting parameters
    col_pp          = [0.21528455710115266, 0.5919540462603717, 0.3825837270552851;
                         0.24756252096251694, 0.43757475330612905, 0.5968141290988245;
                         0.7153368599631209, 0.546895038817448, 0.1270092896093349;
                         0.6772691643574462, 0.3168004639904812, 0.3167958318320575];

    x_size          = 0.19;
    y_size          = 0.15;
    x_pos           = linspace(0.1,0.9-x_size,4);

    %% load stuff                 
    % load behavioural similarities
    load([bids_dir '/sourcedata/spose_similarity.mat'],'spose_sim')

    % load decoding results
    load([res_dir,'/validation-pairwise_decoding_RDM1854'],'mat')
    decoding_1854 = mat; 

    load([res_dir,'/validation-pairwise_decoding_RDM200'],'mat')
    decoding_200 = mat; 

    % load one example output file to get the time vector
    load([res_dir '/pairwise_decoding/P1_pairwise_decoding_1854_block1.mat'], 'res')
    tv = res.a.fdim.values{1}*1000;


    %% RSA: behaviour - MEG
    corr_beh = zeros(size(decoding_1854,3),4);

    for p = 1:4
        for t = 1:size(decoding_1854,3)
            dat = decoding_1854(:,:,t,p);
            corr_beh(t,p)=corr(dat(:),spose_sim(:), 'rows','complete','Type','Pearson');
        end
    end

    save([res_dir '/validation_rsa-behaviour'],'corr_beh')

    %% plot 
    f = figure(1);clf
    f.Position=[0,0,600,700];

    for p = 1:n_participants
        % define threshold based on pre-stimulus onset
        max_preonset = max(corr_beh(tv<=0,p)*-1);

        % plot data for each participant, fill when r > threshold
        ax1 = axes('Position',[x_pos(p),0.5,x_size,y_size],'Units','normalized');
        plot(tv,corr_beh(:,p)*-1,'LineWidth',2,'Color',col_pp(p,:));hold on
        hf = fill([tv,tv(end)],[max(corr_beh(:,p)*-1,max_preonset);max_preonset],col_pp(p,:),'EdgeColor','none','FaceAlpha',0.2);

        % make it look pretty
        ylim([-0.03,.11])
        xlim([tv(1),tv(end)])

        % find onset of the longest shaded cluster
        i=reshape(find(diff([0;corr_beh(:,p)*-1>max_preonset;0])~=0),2,[]);
        [~,jmax]=max(diff(i));
        onset_idx=i(1,jmax);
        onset = tv(onset_idx); 

        % add a marker for onsets
        text(onset,gca().YLim(1), char(8593),'Color',col_pp(p,:), 'FontSize', 20, 'VerticalAlignment', 'bottom', 'HorizontalAlignment','Center','FontName','Helvetica')
        text(onset+15,gca().YLim(1), [num2str(onset) ' ms'],'Color',col_pp(p,:), 'FontSize', 14, 'VerticalAlignment', 'bottom', 'HorizontalAlignment','left')
        set(ax1,'FontSize',14,'box','off','FontName','Helvetica');

        % add subject title
        ax1_title = axes('Position',[x_pos(p)+0.001,0.5+y_size-0.01,0.03,0.03]); 
        text(0,0,['M' num2str(p)],'FontSize',12,'FontName','Helvetica');
        ax1_title.Visible = 'off'; 

        % add labels    
        if p ==1
            ax1.YLabel.String = 'r';
        else
            ax1.YTick = [];
        end
        ax1.XLabel.String = 'time (ms)';

    end

    % save figure
    fn = [figdir,'/validation_rsa-behaviour'];
    tn = tempname;
    print(gcf,'-dpng','-r500',tn)

    im=imread([tn '.png']);
    [i,j]=find(mean(im,3)<255);margin=0;
    imwrite(im(min(i-margin):max(i+margin),min(j-margin):max(j+margin),:),[fn '.png'],'png');

    print([fn '.pdf'],'-dpdf')

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