Implement #274 (histology bit-flip), #343 (Destrieux atlas), #341 (resilient Neurosynth fetch)#380
Merged
Merged
Conversation
#274: Invert BigBrain histology profiles by default read_histology_profile now flips the 8-bit intensity values so that higher numbers correspond to darker, more cell-dense regions, matching the convention used in Paquola et al. 2021 and most downstream BigBrain analyses (the raw BigBrainWarp data uses the opposite convention). Pass `invert=False` to keep the previous behaviour. MPC and gradient computations are correlation-based and therefore invariant to the flip; only direct inspection of profile intensities is affected. #343: Add the Destrieux atlas to fetch_parcellation `fetch_parcellation(template, "destrieux", n_regions, ...)` now returns the FreeSurfer aparc.a2009s parcellation (75 cortical labels per hemisphere). Sourced from nilearn.datasets.fetch_atlas_surf_destrieux on fsaverage5; for other fsaverage* templates we resample with nearest- neighbour interpolation. fslr32k is rejected (FreeSurfer-specific). n_regions is accepted for API consistency but ignored. This is the closest off-the-shelf FreeSurfer atlas BrainStat can ship without hosting new data files; a hosted aparc/Desikan-Killiany option will need a separate download URL and is left as a follow-up. #341: Resilient Neurosynth download meta_analytic_decoder>fetch_neurosynth_data is now retry-safe: - The downloaded zip is validated via java.util.zip.ZipFile before unzip, so truncated downloads surface a clear error instead of MATLAB's terse "Invalid ZIP file" later on. - websave + verify + unzip is wrapped in a small retry loop (3 attempts) and any partial zip is cleaned up between attempts. - After extraction we verify the expected file count and surface a remediation hint if it doesn't match. - find_files now handles a missing data_dir gracefully.
This was referenced May 4, 2026
This was referenced May 4, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Folds three open issues into a single PR. Each is independently scoped, but they're small enough that one PR keeps the review queue tidy.
Closes #274 — Flip the bits on the histological profiles
read_histology_profilenow returns 8-bit intensities so that higher = darker = more cell-dense, matching Paquola et al. 2021 (eLife) and the convention used in most downstream BigBrain analyses. Behaviour is gated on a newinvert: bool = Trueparameter; passinvert=Falseto recover the raw BigBrainWarp values.MPC and gradient computations (
compute_mpc,compute_histology_gradients) are correlation-based and therefore invariant to a global sign flip — they produce identical results either way. Only code that inspects raw profile intensities directly will see a difference.Closes #343 (in part) — atlas coverage for FreeSurfer-based GLM workflows
fetch_parcellation(template, "destrieux", ...)now returns FreeSurfer'saparc.a2009s(Destrieux 2009) parcellation, sourced vianilearn.datasets.fetch_atlas_surf_destrieux. Nativefsaverage5; otherfsaverage*templates are resampled with nearest-neighbour interpolation.fslr32kis rejected with a clear error since the atlas is FreeSurfer-specific.This is the closest off-the-shelf option BrainStat can ship without hosting new data files. The original ask included
aparc(Desikan-Killiany); that one needs a download URL and a small server-side change, so it's flagged as a follow-up rather than rolled in here.Closes #341 — Neurosynth fetch fails on interrupted downloads
meta_analytic_decoder/fetch_neurosynth_datawas leaving truncated.zipfiles on disk after a partialwebsave, then crashing on the next call withInvalid ZIP file. Now:java.util.zip.ZipFile-based integrity check that opens the central directory without extracting (the archive is multi-GB, so we can't afford to extract a probe copy).websave → verify → unzipis wrapped in a 3-attempt retry loop; partial zips are deleted between attempts.find_filesno longer errors whendata_dirdoesn't exist yet.Test plan
pytest brainstat/tests/test_datasets.py— 21 passed, 1 skipped.read_histology_profile's newinvertparameter is honoured (signature inspection); default isTrue.fetch_parcellation(..., \"destrieux\", ...)route exercised through Python.Out of scope (kept open as separate trackers)
# type: ignorefrom SLM: blocked on upstreampython/mypy#10521.data_urls.jsonentry once a stable host (OSF / Zenodo) is decided.