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. 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:

    • residuals.nii.gz --> Residuals of the GLM fit
    • Tstat.nii.gz --> T-statistic of the GLM fit
    • Zstat.nii.gz --> Z-statistic of the GLM fit
    • uncorr_pvals_negative.nii.gz --> Uncorrected p-values of the GLM fit (negative)
    • uncorr_pvals_positive.nii.gz --> Uncorrected p-values of the GLM fit (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 --> 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

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 :)

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.2.tar.gz (14.9 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.2-py3-none-any.whl (15.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for compneuro_tools-0.1.2.tar.gz
Algorithm Hash digest
SHA256 acc9cdfd358576f6aa6c1e0173a0111a18fbc464cbbcec2a5f723ec3ab3c3807
MD5 6355d62bde8f49e7f53e5f03acaf2379
BLAKE2b-256 c27202ebc37feea4559fe67c170c71e1239c4b6fd982bc022ed540b742486e3f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for compneuro_tools-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 996347cb16523e4de57c974127b72c6541844f8b27ee94ab439da6d2875d67b1
MD5 be6b45ece0a97e92af9957c1f7295bad
BLAKE2b-256 d0524a71da54682ad62295a4495874436e26c0104d2ad2b9da861130431dd5ad

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