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

prepare binder and basic jupyter notebook #155

Merged
merged 9 commits into from
Sep 10, 2021
Merged
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
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@ cfg/*
group/*
models/*

# jupyter notebooks
.ipynb_checkpoints

## MATLAB / OCTAVE gitignore template

# From : https://github.com/github/gitignore/blob/master/Global/MATLAB.gitignore


# Windows default autosave extension
*.asv

Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@
[![Documentation Status: stable](https://readthedocs.org/projects/cpp_spm/badge/?version=stable)](https://cpp_spm.readthedocs.io/en/stable/?badge=stable)

**Code quality and style**

[![](https://img.shields.io/badge/Octave-CI-blue?logo=Octave&logoColor=white)](https://github.com/cpp-lln-lab/CPP_BIDS_SPM_pipeline/actions)
![](https://github.com/cpp-lln-lab/CPP_SPM/workflows/CI/badge.svg)

**Unit tests and coverage**

[![codecov](https://codecov.io/gh/Remi-Gau/CPP_SPM/branch/master/graph/badge.svg?token=8IoRQtbFUV)](https://codecov.io/gh/Remi-Gau/CPP_SPM)

**How to cite**
Expand Down
6 changes: 6 additions & 0 deletions binder/apt.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
tree
curl
octave
liboctave-dev
gnuplot
ghostscript
11 changes: 11 additions & 0 deletions binder/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
channels:

- default
- conda-forge

dependencies:

- octave_kernel
- texinfo
- jupyterlab
- datalad=0.14
16 changes: 16 additions & 0 deletions binder/postBuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
mkdir ${HOME}/spm12 && curl -SL https://github.com/spm/spm12/archive/r7487.tar.gz | tar -xzC ${HOME}/spm12 --strip-components 1
curl -SL https://raw.githubusercontent.com/spm/spm-docker/master/octave/spm12_r7487.patch | patch -d ${HOME}/spm12 -p3

cd ${HOME}/spm12/src
make PLATFORM=octave
make PLATFORM=octave install

cd ${HOME}/spm12/@file_array/private
find . -name "mat2file*.*" -print0 | xargs -0 -I{} find '{}' \! -name "*.mex" -delete
find . -name "file2mat*.*" -print0 | xargs -0 -I{} find '{}' \! -name "*.mex" -delete

cd ${HOME}
octave --no-gui --eval "addpath (fullfile (getenv (\"HOME\"), \"spm12\")); savepath ();"

cd ${HOME}/demos/MoAE
make inputs/raw
17 changes: 11 additions & 6 deletions demos/MoAE/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,17 @@ clean:
rm -rf cfg
rm MoAEpilot.zip

data:
datalad install git@gin.g-node.org:/RemiGau/spm_moae_fmriprep.git
datalad get spm_moae_fmriprep/*.json
datalad get spm_moae_fmriprep/sub*/*/*.nii.gz
datalad get spm_moae_fmriprep/sub*/*/*.tsv
datalad get spm_moae_fmriprep/sub*/*/*.json
inputs/raw:
mkdir inputs/ -p
octave $(OCTFLAGS) --eval "run('download_moae_ds.m');exit;"

inputs/fmriprep:
cd inputs && datalad install git@gin.g-node.org:/RemiGau/spm_moae_fmriprep.git
datalad get inputs/spm_moae_fmriprep/*.json
datalad get inputs/spm_moae_fmriprep/sub*/*/*.nii*
datalad get inputs/spm_moae_fmriprep/sub*/*/*.tsv
datalad get inputs/spm_moae_fmriprep/sub*/*/*.json
mv inputs/spm_moae_fmriprep inputs/fmriprep
all: $(roi)

$(preproc): moae_01_preproc.m
Expand Down
8 changes: 6 additions & 2 deletions demos/MoAE/download_moae_ds.m
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
function download_moae_ds(download_data)
function download_moae_ds(download_data, clean)
%
% (C) Copyright 2021 Remi Gau

if nargin < 1
download_data = true;
end

if nargin < 2
clean = false;
end

if download_data

% URL of the data set to download
Expand All @@ -14,7 +18,7 @@ function download_moae_ds(download_data)
working_directory = fileparts(mfilename('fullpath'));

% clean previous runs
if exist(fullfile(working_directory, 'inputs'), 'dir')
if clean && exist(fullfile(working_directory, 'inputs'), 'dir')
rmdir(fullfile(working_directory, 'inputs'), 's');
end

Expand Down
5 changes: 3 additions & 2 deletions demos/MoAE/moae_01_preproc.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,19 @@
clc;

download_data = false;
clean = false;

run ../../initCppSpm.m;

opt = moae_get_option();

download_moae_ds(download_data);
% download_moae_ds(download_data, clean);

% reportBIDS(opt);

opt.pipeline.type = 'preproc';

% bidsCopyInputFolder(opt);
bidsCopyInputFolder(opt);

% In case you just want to run segmentation and skull stripping
% NOTE: skull stripping is also included in 'bidsSpatialPrepro'
Expand Down
4 changes: 1 addition & 3 deletions demos/MoAE/moae_fmriprep_stats.m
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
% This script will run the FFX and contrasts on it of the MoAE dataset
% using the fmriprep preprocessed data
%
% Results might be a bit different from those in the manual as some
% default options are slightly different in this pipeline
% (e.g use of FAST instead of AR(1), motion regressors added)
%
% (C) Copyright 2019 Remi Gau

Expand Down
3 changes: 3 additions & 0 deletions demos/MoAE/moae_get_option_fmriprep_preproc.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@

opt.space = {'MNI152NLin2009cAsym'};

opt.query.desc = {'preproc', 'confounds'};
% opt.query.space = opt.space;

%% DO NOT TOUCH
opt = checkOptions(opt);
saveOptions(opt);
Expand Down
2 changes: 1 addition & 1 deletion demos/face_repetition/face_rep_01_preproc_func.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
clear;
clc;

downloadData = true;
downloadData = false;

run ../../initCppSpm.m;

Expand Down
19 changes: 8 additions & 11 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# this is mostly taken from the spm docker files: https://github.com/spm/spm-docker
FROM ubuntu:cosmic
FROM ubuntu:focal

# basic OS tools install and also octave
RUN apt-get update && apt-get -y install --no-install-recommends \
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y install \
build-essential \
git \
zip unzip \
curl \
git \
octave \
liboctave-dev \
&& apt-get clean \
Expand All @@ -16,7 +15,6 @@ RUN apt-get update && apt-get -y install --no-install-recommends \
/var/lib/apt/lists/* \
/var/log/apt/term*

# install SPM and the relevant patches for octave
RUN mkdir /opt/spm12 \
&& curl -SL https://github.com/spm/spm12/archive/r7487.tar.gz \
| tar -xzC /opt/spm12 --strip-components 1 \
Expand All @@ -30,11 +28,10 @@ RUN mkdir /opt/spm12 \
RUN octave --no-gui --eval "addpath(\"/opt/spm12\"); savepath ();"

# get the CPP BIDS pipeline code
RUN mkdir /CPP_BIDS_pipeline /output /code \
&& git clone https://github.com/cpp-lln-lab/CPP_BIDS_SPM_pipeline.git /CPP_BIDS_pipeline/

RUN octave --no-gui --eval "addpath(genpath(\"/CPP_BIDS_pipeline\")); savepath ();"
RUN mkdir /CPP_SPM /output /code \
&& git clone https://github.com/cpp-lln-lab/CPP_SPM.git /CPP_SPM/

WORKDIR /CPP_BIDS_pipeline
RUN octave --no-gui --eval "addpath(genpath(\"/CPP_SPM/lib\")); savepath ();"
RUN octave --no-gui --eval "addpath(genpath(\"/CPP_SPM/src\")); savepath ();"

RUN git checkout remi-docker_dev
WORKDIR /CPP_SPM
29 changes: 16 additions & 13 deletions docs/source/docker.rst
Original file line number Diff line number Diff line change
@@ -1,26 +1,15 @@
Docker
******

The recipe to build the docker image is in the ``Dockerfile``

Build docker image
==================

To build the image with with octave and SPM the `Dockerfile` just type::

docker build -t cpp_spm:0.0.1 .

This will create an image with the tag name `cpp_spm_octave:0.0.1`

Run docker image
================

The following code would start the docker image and would map 2 folders one for
The following code would pull and start the docker image and would map 2 folders one for
``output`` and one for ``code`` you want to run::

docker run -it --rm \
-v [output_folder]:/output \
-v [code_folder]:/code cpp_spm:0.0.1
-v [code_folder]:/code cpplab/cpp_spm:0.1.0

To test it you can copy the ``MoAEpilot_run.m`` file in the ``demos/MoAE`` folder on
your computer and then start running the docker and type::
Expand All @@ -32,3 +21,17 @@ your computer and then start running the docker and type::

# To run the batch_download_run script
octave --no-gui --eval MoAEpilot_run



Build docker image locally
==========================

If you want to build the docker image locally and not pull it from the docker hub, the recipe to
build the docker image is in the ``Dockerfile``

To build the image with with octave and SPM the `Dockerfile` just type::

docker build -t cpp_spm:0.1.0 .

This will create an image with the tag name `cpp_spm:0.1.0`
Loading