Skip to content

Commit

Permalink
Merge branch 'Deep-MI:dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
taha-abdullah authored Aug 28, 2024
2 parents ef7524e + f2a51b6 commit a667780
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 18 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'
4 changes: 3 additions & 1 deletion Docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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="" \
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion HypVINN/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 3 additions & 1 deletion HypVINN/utils/stats_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
8 changes: 4 additions & 4 deletions recon_surf/recon-surf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
{
Expand All @@ -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"
10 changes: 5 additions & 5 deletions recon_surf/smooth_aparc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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, :]
Expand Down Expand Up @@ -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, :]
Expand Down
20 changes: 18 additions & 2 deletions run_fastsurfer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down

0 comments on commit a667780

Please sign in to comment.