Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] close #340 and #355 #357

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions brainstat/context/histology.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,10 @@ def read_histology_profile(
)

with h5py.File(histology_file, "r") as h5_file:
profiles = h5_file.get(template)[...]
if template == "fslr32k":
profiles = h5_file.get("fs_LR_64k")[...]
else:
profiles = h5_file.get(template)[...]
if civet_template:
fsaverage_surface = fetch_template_surface("fsaverage")
civet_surface = fetch_template_surface(civet_template)
Expand Down Expand Up @@ -191,7 +194,10 @@ def download_histology_profiles(

data_dir = Path(data_dir) if data_dir else data_directories["BIGBRAIN_DATA_DIR"]
data_dir.mkdir(parents=True, exist_ok=True)
output_file = data_dir / ("histology_" + template + ".h5")
if template == "fslr32k":
output_file = data_dir / "histology_fslr32k.h5"
else:
output_file = data_dir / ("histology_" + template + ".h5")

url = read_data_fetcher_json()["bigbrain_profiles"][template]["url"]

Expand Down
10 changes: 9 additions & 1 deletion brainstat/tests/test_histology.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
"""Unit tests for the histology module."""
import pytest
import requests
import numpy as np

from brainstat._utils import read_data_fetcher_json

from brainstat.context.histology import read_histology_profile
parametrize = pytest.mark.parametrize
json = read_data_fetcher_json()

Expand All @@ -19,3 +20,10 @@ def test_urls(template):
"""
r = requests.head(json["bigbrain_profiles"][template]["url"])
assert r.status_code == 200


def test_histology_profiles_is_ndarray():
histology_profiles = read_histology_profile(template="fslr32k")

# Assert that histology_profiles is an ndarray
assert isinstance(histology_profiles, np.ndarray), "histology_profiles should be a NumPy ndarray"
2 changes: 1 addition & 1 deletion brainstat/tests/test_mesh_edges.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,4 @@ def test_nifti_input():
edg = mesh_edges(nifti)

assert edg.shape[1] == 2
assert np.amax(edg) <= nifti.get_data().sum() - 1
assert np.amax(edg) <= nifti.get_fdata().sum() - 1
Loading