Skip to content

Commit

Permalink
Merge branch 'release-1.5.1' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
piloubazin committed May 7, 2024
2 parents 89d037c + 90f35d2 commit b0403d4
Show file tree
Hide file tree
Showing 34 changed files with 3,199 additions and 66 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ jobs:
python-version: ${{ matrix.python-version }}
auto-activate-base: false

- name: Update dependencies
run: |
make update_dep_shasum
- name: Build java dependencies
run: |
./build.sh
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ clean:
rm -rf nighresjava/
rm -rf cbstools-public/
rm -rf imcn-imaging/
rm -rf fbpa-tools/
rm -rf nighres.egg-info/
rm -rf nighres_examples/

Expand Down
59 changes: 58 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@ function join_by { local IFS="$1"; shift; echo "$*"; }
source dependencies_sha.sh
cbstools_repo="https://github.com/piloubazin/cbstools-public.git"
imcntk_repo="https://github.com/piloubazin/imcn-imaging.git"
fbpa_repo="https://github.com/piloubazin/fbpa-tools.git"

release="release-1.5.0"
#release="release-1.5.0"
# for the latest development version
release="master"

# Check the system has the necessary commands
hash wget tar javac jar python3 2>/dev/null || fatal "This script needs the following commands available: wget tar javac jar python3"
Expand Down Expand Up @@ -153,6 +156,59 @@ jar cf ../nighresjava/src/imcntk-lib.jar nl/uva/imcn/libraries/*.class nl/uva/im
cp lib/*.jar ../nighresjava/lib/
cd ..

#
## COMPILE FbpA tools
#

# Get FbpA git clone
test -d fbpa-tools && (
cd fbpa-tools
git checkout $release
git pull
cd ..
) || (
git clone -b $release $fbpa_repo --depth 1
cd fbpa-tools
git checkout
git pull
cd ..
)

# Java dependencies. Order matters
deps=(
"."
"lib/commons-math3-3.5.jar"
)
deps_list=$(join_by ":" "${deps[@]}")

# List of library files needed to run the core functions
source fbpa-tools-files.sh
echo $fbpa_files # result is in $fbpa_files

fbpa_list=$(join_by " " "${fbpa_files[@]}")

# Compilation options
javac_opts=(
# "-d build" # Output dir
"-Xlint:none" # Disable all warnings
# "-server" # ?
"-g" # Generate all debugging info
"-O" # ?
"-deprecation" # Show information about deprecated Java calls
"-encoding UTF-8" # Require UTF-8, rather than platform-specifc
)

echo "Compiling..."
cd fbpa-tools
javac -cp ${deps_list} ${javac_opts[@]} nl/fullbrainpicture/algorithms/*.java ${fbpa_list}

echo "Assembling..."
jar uf ../nighresjava/src/nighresjava.jar nl/fullbrainpicture/algorithms/*.class
jar cf ../nighresjava/src/fbpa-lib.jar nl/fullbrainpicture/libraries/*.class nl/fullbrainpicture/structures/*.class nl/fullbrainpicture/utilities/*.class

cp lib/*.jar ../nighresjava/lib/
cd ..

#
## WRAP TO PYTHON
#
Expand All @@ -165,6 +221,7 @@ jcc_args=(
# Dependencies
"--include src/cbstools-lib.jar"
"--include src/imcntk-lib.jar"
"--include src/fbpa-lib.jar"
"--include lib/commons-math3-3.5.jar"
"--include lib/Jama-mipav.jar"

Expand Down
45 changes: 42 additions & 3 deletions build_local_nighresjava.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ function join_by { local IFS="$1"; shift; echo "$*"; }
# define here the local folders for your installation of CBSTools, IMCNtk and Nighres
cbstools_local="/home/pilou/Code/github/cbstools-public"
imcntk_local="/home/pilou/Code/github/imcn-imaging"
fbpa_local="/home/pilou/Code/github/fbpa-tools"
nighres_local="/home/pilou/Code/github/nighres"

# Check the system has the necessary commands
Expand Down Expand Up @@ -116,18 +117,55 @@ javac_opts=(
)

echo "Compiling..."
#cd cbstools-public
cd $imcntk_local
#mkdir -p build
$JAVA_HOME/bin/javac -cp ${deps_list} ${javac_opts[@]} nl/uva/imcn/algorithms/*.java $imcntk_list

echo "Assembling..."
#jar cf imcntk.jar nl/uva/imcn/algorithms/*.class
$JAVA_HOME/bin/jar uf $nighres_local/nighresjava/src/nighresjava.jar nl/uva/imcn/algorithms/*.class
$JAVA_HOME/bin/jar cf $nighres_local/nighresjava/src/imcntk-lib.jar nl/uva/imcn/libraries/*.class nl/uva/imcn/methods/*.class nl/uva/imcn/structures/*.class nl/uva/imcn/utilities/*.class

cp lib/*.jar $nighres_local/nighresjava/lib/

#
## COMPILE FbpA tools
#

# Java dependencies. Order matters
deps=(
"."
"lib/commons-math3-3.5.jar"
)
deps_list=$(join_by ":" "${deps[@]}")

# List of library files needed to run the core functions
source $nighres_local/fbpa-tools-files.sh
echo $fbpa_files # result is in $fbpa_files

fbpa_list=$(join_by " " "${fbpa_files[@]}")

# Compilation options
javac_opts=(
# "-d build" # Output dir
"-Xlint:none" # Disable all warnings
"-server" # ?
"-g" # Generate all debugging info
"-O" # ?
"-deprecation" # Show information about deprecated Java calls
"-encoding UTF-8" # Require UTF-8, rather than platform-specifc
)

echo "Compiling..."
cd $fbpa_local
#mkdir -p build
$JAVA_HOME/bin/javac -cp ${deps_list} ${javac_opts[@]} nl/fullbrainpicture/algorithms/*.java $fbpa_list

echo "Assembling..."
#jar cf imcntk.jar nl/uva/imcn/algorithms/*.class
$JAVA_HOME/bin/jar uf $nighres_local/nighresjava/src/nighresjava.jar nl/fullbrainpicture/algorithms/*.class
$JAVA_HOME/bin/jar cf $nighres_local/nighresjava/src/fbpa-lib.jar nl/fullbrainpicture/libraries/*.class nl/fullbrainpicture/structures/*.class nl/fullbrainpicture/utilities/*.class

cp lib/*.jar $nighres_local/nighresjava/lib/

#
## WRAP TO PYTHON
#
Expand All @@ -140,6 +178,7 @@ jcc_args=(
# Dependencies
"--include src/cbstools-lib.jar"
"--include src/imcntk-lib.jar"
"--include src/fbpa-lib.jar"
"--include lib/commons-math3-3.5.jar"
"--include lib/Jama-mipav.jar"

Expand Down
27 changes: 15 additions & 12 deletions create_container_recipe.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,30 @@ else

fi

docker run --rm repronim/neurodocker:0.7.0 generate "${container_type}" \
--base debian:stretch-slim \
docker run ${expose} \
--rm repronim/neurodocker:0.9.5 generate "${container_type}" \
--base-image debian:stable \
--pkg-manager apt \
--install "openjdk-8-jdk git wget build-essential software-properties-common libffi-dev" \
--install "openjdk-17-jdk git wget build-essential software-properties-common libffi-dev" \
--env JAVA_HOME="/docker-java-temurin-home" \
--env JCC_JDK="/docker-java-temurin-home" \
--run 'ln -svT "/usr/lib/jvm/java-17-openjdk-$(dpkg --print-architecture)" /docker-java-temurin-home' \
--miniconda \
create_env="nighres" \
conda_install="python=3.9 pip jcc Nilearn" \
activate="true" \
--env JAVA_HOME="/docker-java-home" \
--env JCC_JDK="/docker-java-home" \
--run 'ln -svT "/usr/lib/jvm/java-8-openjdk-$(dpkg --print-architecture)" /docker-java-home' \
version="latest" \
env_name="nighres" \
env_exists="false" \
conda_install="python=3.9 pip JCC Nilearn" \
--copy build.sh cbstools-lib-files.sh imcntk-lib-files.sh dependencies_sha.sh setup.py setup.cfg MANIFEST.in README.rst LICENSE /nighres/ \
--copy nighres /nighres/nighres \
--workdir /nighres \
--run "conda init && . /root/.bashrc && conda activate nighres && conda info --envs && ./build.sh && rm -rf cbstools-public imcn-imaging nighresjava/build nighresjava/src" \
--run "conda init && . /root/.bashrc && activate nighres && conda info --envs && pip install jcc && ./build.sh && rm -rf cbstools-public imcn-imaging nighresjava/build nighresjava/src" \
--miniconda \
use_env="nighres" \
version="latest" \
installed="true" \
env_name="nighres" \
conda_install="jupyterlab" \
pip_install="." \
--copy docker/jupyter_notebook_config.py /etc/jupyter \
"${expose}" \
--user neuro \
--workdir /home/neuro >"${output_file}"

Expand Down
7 changes: 7 additions & 0 deletions fbpa-tools-files.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
fbpa_files=(
"nl/fullbrainpicture/libraries/ObjectTransforms.java"

"nl/fullbrainpicture/structures/BinaryHeap4D.java"

"nl/fullbrainpicture/utilities/Numerics.java"
)
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,38 @@ Cerebellum-WM 60.0 10.0 1.00
Cerebrum-WML 60.0 10.0 1.00
Cerebrum-WMR 60.0 10.0 1.00

Intensity Prior: bflidark07
Background 0.0 20.0 1.00
Dura 20.0 20.0 1.00
Arteries 150.0 30.0 1.00
Sulcal-CSF 45.0 20.0 1.00
VentricleL 150.0 30.0 1.00
VentricleR 150.0 30.0 1.00
Ventricle3 150.0 30.0 1.00
Ventricle4 20.0 20.0 1.00
ChoroidPlexusL 20.0 20.0 1.00
ChoroidPlexusR 20.0 20.0 1.00
Sinuses 20.0 20.0 1.00
Cerebellum-GM 95.0 20.0 1.00
Cerebrum-GML 90.0 20.0 1.00
Cerebrum-GMR 90.0 20.0 1.00
AmygdalaL 80.0 20.0 1.00
AmygdalaR 80.0 20.0 1.00
CaudateL 95.0 20.0 1.00
CaudateR 95.0 20.0 1.00
HippocampusL 85.0 20.0 1.00
HippocampusR 85.0 20.0 1.00
PutamenL 90.0 20.0 1.00
PutamenR 90.0 20.0 1.00
ThalamusL 80.0 20.0 1.00
ThalamusR 80.0 20.0 1.00
GlobusPallidusL 80.0 20.0 1.00
GlobusPallidusR 80.0 20.0 1.00
Brainstem 85.0 20.0 1.00
Cerebellum-WM 70.0 20.0 1.00
Cerebrum-WML 65.0 20.0 1.00
Cerebrum-WMR 65.0 20.0 1.00

Intensity Prior: bfiqrlog
Background 0.0 0.5 1.00
Dura 0.0 0.5 1.00
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,38 @@ Cerebellum-WM 60.0 10.0 1.00
Cerebrum-WML 60.0 10.0 1.00
Cerebrum-WMR 60.0 10.0 1.00

Intensity Prior: bflidark07
Background 0.0 20.0 1.00
Dura 20.0 20.0 1.00
Arteries 20.0 30.0 1.00
Sulcal-CSF 20.0 30.0 1.00
VentricleL 150.0 30.0 1.00
VentricleR 150.0 30.0 1.00
Ventricle3 150.0 30.0 1.00
Ventricle4 20.0 20.0 1.00
ChoroidPlexusL 20.0 20.0 1.00
ChoroidPlexusR 20.0 20.0 1.00
Sinuses 20.0 20.0 1.00
Cerebellum-GM 95.0 10.0 1.00
Cerebrum-GML 95.0 10.0 1.00
Cerebrum-GMR 95.0 10.0 1.00
AmygdalaL 80.0 20.0 1.00
AmygdalaR 80.0 20.0 1.00
CaudateL 95.0 20.0 1.00
CaudateR 95.0 20.0 1.00
HippocampusL 85.0 20.0 1.00
HippocampusR 85.0 20.0 1.00
PutamenL 90.0 20.0 1.00
PutamenR 90.0 20.0 1.00
ThalamusL 80.0 20.0 1.00
ThalamusR 80.0 20.0 1.00
GlobusPallidusL 80.0 20.0 1.00
GlobusPallidusR 80.0 20.0 1.00
Brainstem 85.0 20.0 1.00
Cerebellum-WM 70.0 20.0 1.00
Cerebrum-WML 65.0 20.0 1.00
Cerebrum-WMR 65.0 20.0 1.00

Intensity Prior: bfiqrlog
Background 0.0 0.5 1.00
Dura 0.0 0.5 1.00
Expand Down
1 change: 1 addition & 0 deletions nighres/data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
from nighres.data.download_data import download_MP2RAGEME_sample
from nighres.data.download_data import download_MP2RAGEME_testdata
from nighres.data.download_data import download_AHEAD_template
from nighres.data.download_data import download_AHEADmni2009b_template
67 changes: 67 additions & 0 deletions nighres/data/download_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,3 +419,70 @@ def download_AHEAD_template(data_dir=None, overwrite=False):
return {'qr1': file_targets[0],
'qr2s': file_targets[1],
'qsm': file_targets[2]}

def download_AHEADmni2009b_template(data_dir=None, overwrite=False):
"""
Downloads the AHEAD group template in MNI 2009b space _[1].
Parameters
----------
data_dir: str
Writeable directory in which downloaded atlas files should be stored. A
subdirectory called 'ahead-template' will be created in this location
(default is ATLAS_DIR)
overwrite: bool
Overwrite existing files in the same exact path (default is False)
Returns
----------
dict
Dictionary with keys pointing to the location of the downloaded files
* qr1 : path to quantitative R1 map image
* qr2s : path to quantitative R2* map image
* qsm : path to QSM image
* qpd : path to semi-quantitative PD image
References
----------
.. [1] Alkemade et al (under review). The Amsterdam Ultra-high field adult
lifespan database (AHEAD): A freely available multimodal 7 Tesla
submillimeter magnetic resonance imaging database.
"""

if (data_dir is None):
data_dir = ATLAS_DIR

data_dir = os.path.join(data_dir, 'ahead-template')

if not os.path.isdir(data_dir):
os.makedirs(data_dir)

figshare = 'https://uvaauas.figshare.com/ndownloader/files/'

# older version of the template
# file_sources = [figshare + x for x in
# ['22679537','22679543','22679546','']]
file_sources = [figshare + x for x in
['34892901','34892907','34892883','41498217']]

file_targets = [os.path.join(data_dir, filename) for filename in
['ahead_mni2009b_med_qr1.nii.gz',
'ahead_mni2009b_med_qr2s.nii.gz',
'ahead_mni2009b_med_qsm.nii.gz',
'ahead_mni2009b_med_qpd.nii.gz']]

for source, target in zip(file_sources, file_targets):

if os.path.isfile(target) and overwrite is False:
print("\nThe file {0} exists and overwrite was set to False "
"-- not downloading.".format(target))
else:
print("\nDownloading to {0}".format(target))
urlretrieve(source, target)

return {'qr1': file_targets[0],
'qr2s': file_targets[1],
'qsm': file_targets[2],
'qpd': file_targets[3]}

2 changes: 1 addition & 1 deletion nighres/filtering/recursive_ridge_diffusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def recursive_ridge_diffusion(input_image, ridge_intensities, ridge_filter,
rrd.setMaxIterations(max_iter)
rrd.setMaxDifference(max_diff)
rrd.setDetectionThreshold(threshold)
rrd.setUseScale(rescale)
if dimensions[2]>1: rrd.setUseScale(rescale)

rrd.setDimensions(dimensions[0], dimensions[1], dimensions[2])
rrd.setResolutions(resolution[0], resolution[1], resolution[2])
Expand Down
1 change: 1 addition & 0 deletions nighres/intensity/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
from nighres.intensity.mp2rage_t1_mapping import mp2rage_t1_from_uni
from nighres.intensity.phase_unwrapping import phase_unwrapping
from nighres.intensity.t2s_optimal_combination import t2s_optimal_combination
from nighres.intensity.boundary_sharpness import boundary_sharpness

0 comments on commit b0403d4

Please sign in to comment.