GithubHelp home page GithubHelp logo

skjerns / tdlm-python Goto Github PK

View Code? Open in Web Editor NEW

This project forked from yunzheliu/tdlm

0.0 0.0 0.0 766 KB

Python code for running TDLM (temporally delayed linear modelling)

License: GNU General Public License v3.0

MATLAB 58.86% Python 41.14%

tdlm-python's Introduction

tdlm-python's People

Contributors

skjerns avatar yunzheliu avatar

Watchers

 avatar  avatar

tdlm-python's Issues

Add time window approach

In Toby Wise's paper a windowed TDLM approach is presented.

Task:

  • Implement windowed approach
  • should take arguments win_size
  • should take argument aggr_func which is a function that post-processes the output of for each window, e.g. taking the mean differential replay

possible skeleton

def mean_diff(seq_fwd, seq_bkw):
    # calculate the mean differential sequenceness
    mean_diff = np.mean(seq_fwd-seq_bkw)
    return mean_diff 

def compute_windowed(preds, tf, win_size, aggr_func= seq_type='glm/crosscorr', ...):
    # ...
    win_values = []
    for win in windows:
        seq_fwd_win, seq_bkw_win = compute_glm(preds_win)
        aggregated = aggr_func(seq_fwd_win, seq_bkw_win)
        win_values += [aggregated]
    # ....
    # possibly convert win_values into np.ndarray if possible?
    return win_values 

Add n-step computation

Add feature to compute n-step TDLM/cross-correlation.

this is slightly more complicated to implement, haven't thought through yet what's the best option. Feel free to add ideas.

Task:

  • should either take a transition matrix that will automatically be advanced
  • alternatively: a list of transition matrices for each step

possible skeleton

def compute_glm_nstep(preds, tf, n_steps=x...)
    preds_step = preds.copy()
    for step in range(n_steps):
        tf_step = get_next_step_tf(tf)
        fwd, bkw = compute_glm(preds_step , tf, ...)
        # ...

Problems:

  • Do we map AB->C or A->BC ? Or both and take mean? Does it even make a difference?
  • How do we perform the permutations accurately per step?
  • How to implement alpha frequency correction?

Add EEG simulation

Two functions should be added for simulation purposes:

simulate_eeg_resting_state to create fake M/EEG data and simulate_eeg_localizer to create localizer data

Potentially either yunzhes code can be translated to python or alternatively there are packages to simulate EEG that could be called here.

Replace unique_perms

Currently we're still using unique_permutations which is a port from MATLAB

def unique_permutations(X, k=None):

It would be better to have a more performant and pythonic implementation.

Also add more functions based on the suggestions in the TDLM methods paper (e.g. exclude real transitions from the shuffles)

Setup CI and tests

A CI should be setup using GitHub actions and more tests need to be written.

TF per trial

Currently only on transition matrix can be supplied for all trials. There should be a helper function that takes several prediction trials (3d matrix) and a list of TFs (and TBs) with expected transitions for each trial

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.