Skip to main content

A collection of simple yet useful "brain gardening tools" for my PhD works in CompNeuroBilbaoLab.

Project description

CompNeuro Tools

PyPI version

My personal collection of simple yet useful "brain gardening tools" for my PhD works in CompNeuroBilbaoLab!

Requirements

Use Linux or MacOS. I work with WSL2 in Windows with a Debian distro, and it works fine.

  • Python 3.11 or higher
  • FSL 6.0 or higher
  • AFNI 25.0.09 'Severus Alexander' or higher. I recommend putting it in an apptainer image as it is a bit tricky to install in some systems. You can get it running this command, (assuming you have apptainer installed):
    apptainer build AFNI.sif docker://afni/afni_make_build:AFNI_25.0.09
    
    Then set you environment variable $AFNI_IMAGE_PATH to the path of the image.

Tools

Each CLI tool has a --help option that will show you how to use it. You can also check the code for more details.

  • fit_glm --> Since I do not trust how FSL fits GLMs and sometimes the documentation is a bit lacking, here you go. I use it for fitting my GLMs. Works with design matrices and contrast matrices in .txt format (not in FSL's format!). This code is largely based on Ibai Diez's MATLAB code (thank you Ibai for letting me write my own Python version c:). The list of output files, for each contrast:

    • residuals.nii.gz --> Residuals of the fitting
    • betas.nii.gz --> Beta coefficients of the fitting
    • Tstat.nii.gz --> T-statistic of the specific contrast
    • Zstat.nii.gz --> Z-statistic of the specific contrast
    • uncorr_pvals_negative.nii.gz --> Uncorrected p-values of the specific contrast (negative)
    • uncorr_pvals_positive.nii.gz --> Uncorrected p-values of the specific contrast (positive)
  • cluster_correction_mc --> Correct the clusters in your statistical maps using Monte Carlo simulations. I use it for correcting clusters in my statistical maps after running fit_glm. Uses AFNI for:

    1. estimating the smoothness of your residuals.
    2. running the Monte Carlo simulations based on the smoothness to estimate the critical cluster sizes according to a set of p-values.
    3. correcting the clusters in your statistical maps using the critical cluster sizes.
  • match_groups_in_table --> (WIP) If you have two groups (in the same dataframe) and want to match them based on a continuous variable. I use it for age matching. It makes an initial match taking participants from the majority group until it arrives to the number of participants in the minority group. Then, it keeps adding the closest participants from the majority group and making statistical tests until it arrives to statistical significance. It returns a dataframe with the matched participants.

  • atlas_overlap --> Informs about the overlap between a binary mask and a given atlas. I use it for checking the overlap between my statistically significant cluster masks and atlases of interest. It returns a dataframe with the overlap between the binary mask and each region in the atlas in percentage and in number of voxels.

Installation (User)

You can install the package using pip, as it is available on PyPI:

pip install compneuro-tools

We like to use uv for managing our Python environments. If you want to install the package using uv, you can do it like this:

uv pip install compneuro-tools

Installation (Developer)

  1. Clone this repo.
  2. Install uv (see how to install it in the uv documentation)
  3. Create a virtual environment in the repo folder with uv: uv venv .venv (minimum python version is 3.11)
  4. Activate the virtual environment: source .venv/bin/activate
  5. Install the dependencies: uv sync (or if you prefer uv pip install -e <path_to_this_repo>)
  6. Done :)

How to use the package

You can find a comprehensive tutorial here

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

compneuro_tools-0.1.3.tar.gz (23.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

compneuro_tools-0.1.3-py3-none-any.whl (26.0 kB view details)

Uploaded Python 3

File details

Details for the file compneuro_tools-0.1.3.tar.gz.

File metadata

  • Download URL: compneuro_tools-0.1.3.tar.gz
  • Upload date:
  • Size: 23.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.4.30

File hashes

Hashes for compneuro_tools-0.1.3.tar.gz
Algorithm Hash digest
SHA256 d3d153b40c57b167058989983ff46d0b464d07c7a54606febc2ee6ad6e22c0db
MD5 c7e330c10f6595c3094e30de8368dabf
BLAKE2b-256 b68127a6cce4429f9a1232d862bdad6240c79030e996b341aa7da83d3b8cf88b

See more details on using hashes here.

File details

Details for the file compneuro_tools-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for compneuro_tools-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c0aad8a255607c94f46514ff2ac22e6d9122b1c646e5d1f8ab7524f475f21fe2
MD5 217e89f72e3c3646912d577aba60ea30
BLAKE2b-256 65fd58f780f2aef5397db1756236026010a0ecdc048f241d2d45137b7bed8c73

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page