MIC-DKFZ/HD-BET

hd-bet not working on HPC cluster

tommydino93 opened this issue · 2 comments

Hi All!

I was trying to run hd-bet on an HPC cluster from within a python script.

The steps I followed were:

  1. activate conda environment on the cluster
  2. git clone https://github.com/MIC-DKFZ/HD-BET
  3. cd HD-BET
  4. pip install -e .
  5. Packages are installed correctly (e.g. torch, ..) and in the end I get Successfully installed HD-BET

However, when I invoke it from the python script with, for instance,

# run brain extraction on CPU
hd_bet_cpu = ["hd-bet", "-i", angio_path, "-device", "cpu", "-mode", "fast", "-tta", "0"]
process = subprocess.Popen(hd_bet_cpu, stdout=subprocess.PIPE)  # pass the list as input to Popen
out = process.communicate()[0]

the script finishes, but the command is not executed. Also, if I check the error logs, I get:

/var/spool/slurm/job381401/slurm_script: line 14: activate: No such file or directory
Traceback (most recent call last):
File "/home/to5743/miniconda3/envs/aneurysms/bin/hd-bet", line 6, in
exec(compile(open(file).read(), file, 'exec'))
File "/home/to5743/miniconda3/envs/aneurysms/bin/HD-BET/HD_BET/hd-bet", line 119, in
run_hd_bet(input_files, output_files, mode, config_file, device, pp, tta, save_mask, overwrite_existing)
File "/home/to5743/miniconda3/envs/aneurysms/bin/HD-BET/HD_BET/run.py", line 83, in run_hd_bet
data, data_dict = load_and_preprocess(in_fname)
File "/home/to5743/miniconda3/envs/aneurysms/bin/HD-BET/HD_BET/data_loading.py", line 46, in load_and_preprocess
images[k] = preprocess_image(images[k], is_seg=False, spacing_target=(1.5, 1.5, 1.5))
File "/home/to5743/miniconda3/envs/aneurysms/bin/HD-BET/HD_BET/data_loading.py", line 21, in preprocess_image
image = resize_image(image, spacing, spacing_target).astype(np.float32)
File "/home/to5743/miniconda3/envs/aneurysms/bin/HD-BET/HD_BET/data_loading.py", line 10, in resize_image
return resize(image, new_shape, order=order, mode='edge', cval=0, anti_aliasing=False)
TypeError: resize() got an unexpected keyword argument 'anti_aliasing'

Any idea on how to get around this? By the way, the exact same scrpit runs correctly when I run it locally (i.e. the brain mask is created)

Thanks a lot in advance :)

Hi tommy,
no idea because this seems to be specific to your cluster. But since you are calling hd-bet from within python you might just as well use the python interface:

def run_hd_bet(mri_fnames, output_fnames, mode="accurate", config_file=os.path.join(HD_BET.__path__[0], "config.py"), device=0,

That should work no matter what.
Best,
Fabian

Hi Fabian,

Thanks a lot!

It's very weird indeed. In the end, I made it work by not installing it with pip install -e ., but simply downloading the directory where I have my python script and then invoking the function run_hd_bet as you said.

Thanks again,
Tommy