diff --git a/.github/workflows/doc.yml b/.github/workflows/doc.yml index 16640a20..3336a7fc 100644 --- a/.github/workflows/doc.yml +++ b/.github/workflows/doc.yml @@ -41,7 +41,8 @@ jobs: !doc-build/.doctrees deploy: - if: github.event_name == 'push' + # only on push to dev or stable + if: ${{ github.event_name == 'push' && contains(fromJSON('["dev", "stable"]'), github.ref_name) }} needs: build timeout-minutes: 10 runs-on: ubuntu-latest @@ -56,12 +57,12 @@ jobs: with: name: doc path: doc - - name: Deploy dev documentation + - name: Deploy {dev,stable} documentation uses: peaceiris/actions-gh-pages@v4 with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: doc - # destination_dir: github.event.ref_name will be dev or stable - destination_dir: ${{ github.event.ref_name }} + # destination_dir: github.ref_name will be dev or stable + destination_dir: ${{ github.ref_name }} user_name: 'github-actions[bot]' user_email: 'github-actions[bot]@users.noreply.github.com' diff --git a/Docker/Dockerfile b/Docker/Dockerfile index d1dfd0c3..9eb14c75 100644 --- a/Docker/Dockerfile +++ b/Docker/Dockerfile @@ -162,6 +162,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* # Add FreeSurfer and python Environment variables +# DO_NOT_SEARCH_FS_LICENSE_IN_FREESURFER_HOME=true deactivates the search for FS_LICENSE in FREESURFER_HOME ENV OS=Linux \ FS_OVERRIDE=0 \ FIX_VERTEX_AREA="" \ @@ -171,7 +172,8 @@ ENV OS=Linux \ PYTHONUNBUFFERED=0 \ MPLCONFIGDIR=/tmp \ PATH=/venv/bin:/opt/freesurfer/bin:$PATH \ - MPLCONFIGDIR=/tmp/matplotlib-config + MPLCONFIGDIR=/tmp/matplotlib-config \ + DO_NOT_SEARCH_FS_LICENSE_IN_FREESURFER_HOME="true" # create matplotlib config dir; make sure we use bash and activate conda env # (in case someone starts this interactively) diff --git a/HypVINN/inference.py b/HypVINN/inference.py index 4cc42f97..10134526 100644 --- a/HypVINN/inference.py +++ b/HypVINN/inference.py @@ -320,7 +320,7 @@ def eval(self, val_loader: DataLoader, pred_prob: torch.Tensor, out_scale: float images = batch["image"].to(self.device) scale_factors = batch["scale_factor"].to(self.device) - weight_factors = batch["weight_factor"].to(self.device) + weight_factors = batch["weight_factor"].to(self.device, dtype=torch.float32) pred = self.model(images, scale_factors, weight_factors, out_scale) diff --git a/HypVINN/utils/stats_utils.py b/HypVINN/utils/stats_utils.py index b28da5fa..5fee8ca5 100644 --- a/HypVINN/utils/stats_utils.py +++ b/HypVINN/utils/stats_utils.py @@ -71,5 +71,7 @@ def compute_stats( args.patch_size = 32 args.device = "auto" args.lut = FASTSURFER_ROOT / "FastSurferCNN/config/FreeSurferColorLUT.txt" - args.allow_root = False + # We check for this in the parent code + # TODO: it would be better to populate this properly + args.allow_root = True return main(args) diff --git a/recon_surf/recon-surf.sh b/recon_surf/recon-surf.sh index 708aa825..d3eba901 100755 --- a/recon_surf/recon-surf.sh +++ b/recon_surf/recon-surf.sh @@ -389,7 +389,7 @@ echo "Log file for Conform test" > "$CONFORM_LF" # check for input conformance cmd="$python $FASTSURFER_HOME/FastSurferCNN/data_loader/conform.py -i $t1 --check_only --vox_size min --verbose" -RunIt "$cmd" "$LF" |& tee -a "$CONFORM_LF" +RunIt "$cmd" "$LF" 2>&1 | tee -a "$CONFORM_LF" # look into the CONFORM_LF to find the voxel sizes, the second conform.py call will check the legality of vox_size vox_size=$(grep -E " - Voxel Size " "$CONFORM_LF" | cut -d' ' -f5 | cut -d'x' -f1) @@ -835,7 +835,7 @@ if [ "$DoParallel" == 1 ] ; then echo "" echo " RUNNING HEMIs in PARALLEL !!! " echo "" - } |& tee -a "$LF" + } | tee -a "$LF" RunBatchJobs "$LF" "${CMDFS[@]}" fi @@ -1088,7 +1088,7 @@ tRunHours=$(printf %6.3f "$tRunHours") echo "Started at $StartTime" echo "Ended at $EndTime" echo "#@#%# recon-surf-run-time-hours $tRunHours" -} |& tee -a "$LF" +} | tee -a "$LF" # Create the Done File { @@ -1113,7 +1113,7 @@ tRunHours=$(printf %6.3f "$tRunHours") echo "CMDPATH $0" echo "CMDARGS ${inputargs[*]}" } > "$DoneFile" -echo "recon-surf.sh $subject finished without error at $(date)" |& tee -a "$LF" +echo "recon-surf.sh $subject finished without error at $(date)" | tee -a "$LF" cmd="$python ${binpath}utils/extract_recon_surf_time_info.py -i $LF -o $SUBJECTS_DIR/$subject/scripts/recon-surf_times.yaml" RunIt "$cmd" "/dev/null" diff --git a/recon_surf/smooth_aparc.py b/recon_surf/smooth_aparc.py index 5b21249b..43a063e8 100644 --- a/recon_surf/smooth_aparc.py +++ b/recon_surf/smooth_aparc.py @@ -212,8 +212,8 @@ def mode_filter( # get rid of rows that have uniform vote (or are empty) # for this to work no negative numbers should exist # get row counts, max and sums - rmax = nlabels.max(1).A.squeeze() - sums = nlabels.sum(axis=1).A1 + rmax = nlabels.max(1).toarray().squeeze() + sums = np.asarray(nlabels.sum(axis=1)).ravel() counts = np.diff(nlabels.indptr) # then keep rows where max*counts differs from sums rmax = np.multiply(rmax, counts) @@ -224,7 +224,7 @@ def mode_filter( # since we have only rows that were non-uniform, they should not become empty # rows may become unform: we still need to vote below to update this label if novote: - rr = np.in1d(nlabels.data, novote) + rr = np.isin(nlabels.data, novote) nlabels.data[rr] = 0 nlabels.eliminate_zeros() # run over all rows and compute mode (maybe vectorize later) @@ -303,7 +303,7 @@ def smooth_aparc(surf, labels, cortex = None): noncortids = np.where(~mask) # remove triangles where one vertex is non-cortex to avoid these edges to vote on neighbors later - rr = np.in1d(faces, noncortids) + rr = np.isin(faces, noncortids) rr = np.reshape(rr, faces.shape) rr = np.amax(rr, 1) faces = faces[~rr, :] @@ -342,7 +342,7 @@ def smooth_aparc(surf, labels, cortex = None): ) fillids = np.where(labels == fillonlylabel)[0] labels[fillids] = 0 - rr = np.in1d(faces, fillids) + rr = np.isin(faces, fillids) rr = np.reshape(rr, faces.shape) rr = np.amax(rr, 1) faces = faces[~rr, :] diff --git a/run_fastsurfer.sh b/run_fastsurfer.sh index 8487eba8..9b1974a2 100755 --- a/run_fastsurfer.sh +++ b/run_fastsurfer.sh @@ -697,8 +697,24 @@ then msg="The surface pipeline and the talairach-registration in the segmentation pipeline require a FreeSurfer License" if [[ -z "$FS_LICENSE" ]] then - echo "ERROR: $msg, but no license was provided via --fs_license or the FS_LICENSE environment variable." - exit 1; + msg="$msg, but no license was provided via --fs_license or the FS_LICENSE environment variable." + if [[ "$DO_NOT_SEARCH_FS_LICENSE_IN_FREESURFER_HOME" != "true" ]] && [[ -n "$FREESURFER_HOME" ]] + then + echo "WARNING: $msg Checking common license files in \$FREESURFER_HOME." + for filename in "license.dat" "license.txt" ".license" + do + if [[ -f "$FREESURFER_HOME/$filename" ]] + then + echo "Trying with '$FREESURFER_HOME/$filename', specify a license with --fs_license to overwrite." + export FS_LICENSE="$FREESURFER_HOME/$filename" + break + fi + done + if [[ -z "$FS_LICENSE" ]]; then echo "ERROR: No license found..." ; exit 1 ; fi + else + echo "ERROR: $msg" + exit 1; + fi elif [[ ! -f "$FS_LICENSE" ]] then echo "ERROR: $msg, but the provided path is not a file: $FS_LICENSE."