Cannot import name: scipy.misc.imresize

Hi everyone,
When using the import

from pylinac.core.image import Image, DicomImage, FileImage, ArrayImage

I get an error

from scipy.misc import imresize

ImportError: cannot import name ‘imresize’ from ‘scipy.misc’ (C:.…\Anaconda3\lib\site-packages\scipy\misc_init_.py)

From what i understand Pylinac does not pull a scipy version that has included scipy.misc.imresize (scipy.misc.imresize removed from version 1.3.0 of SciPy. · Issue #187 · jrkerns/pylinac · GitHub)
However, how do i implement the suggested skimage.transform.resize instead? Has anyone come across this essue?

Best wishes

Tried with Pillow?

Maybe this:

https://docs.scipy.org/doc/scipy-1.2.1/reference/generated/scipy.misc.imresize.html

can help you…

If you’re getting this error it means you must be on an older version of pylinac (<=2.2.6). It was removed here: closes #187 · jrkerns/pylinac@1df3432 · GitHub and documented in the changelog here: Changelog — pylinac 2.4.0 documentation

If you want similar behavior I suggest using scikit-image’s transform.resize function: Rescale, resize, and downscale — skimage v0.19.0.dev0 docs (scikit-image.org)

I have tried opgrading pylinac by pip install pylinac --upgrade --user, however, it says that it is already version 2.4.0.1. I still get the error.

If i look at the file adress for image.py there are two versions of image.py, one named with a conflicting copy by your name, as well as other conflicted copies of geometry.py and io.py.
This is what they contain:

image (jameslaptop’s conflicted copy 2018-11-01)

import copy
from collections import Counter
from datetime import datetime
from io import BytesIO
import os.path as osp
import os

import pydicom
from pydicom.errors import InvalidDicomError
import matplotlib.pyplot as plt
import numpy as np
from PIL import Image as pImage
from scipy import ndimage
from scipy.misc import imresize
import scipy.ndimage.filters as spf

from .utilities import is_close, minmax_scale
from .decorators import type_accept, value_accept
from .geometry import Point
from .io import get_url, TemporaryZipDirectory, retrieve_filenames, is_dicom_image
from .profile import stretch as stretcharray
from …settings import get_dicom_cmap

image.py

import copy
from collections import Counter
from datetime import datetime
from io import BytesIO
import re
import os.path as osp
import os
from typing import Union, Sequence, List, Any, Tuple, Optional

import pydicom
from pydicom.errors import InvalidDicomError
import matplotlib.pyplot as plt
import numpy as np
from PIL import Image as pImage
from scipy import ndimage
import scipy.ndimage.filters as spf
import argue

from .utilities import is_close
from .geometry import Point
from .io import get_url, TemporaryZipDirectory, retrieve_filenames, is_dicom_image, retrieve_dicom_file
from .profile import stretch as stretcharray
from .typing import NumberLike
from …settings import get_dicom_cmap, PATH_TRUNCATION_LENGTH

Both of the image.py does not contain the same code as the one shown in closes #187 · jrkerns/pylinac@1df3432 · GitHub , in addition to the calls there miss some other code snippets in the conflicted copy. I guess pylinac uses the one actually named image.py, and since this code contains the call for imresize i could try to implement the opdates you introduced in the opgrade to 2.4.0.0 to that file.

tirsdag den 9. februar 2021 kl. 14.54.54 UTC+1 skrev jker...@gmail.com:

I got around the issue such that i no longer need to call pylinac.core.image.

I will have to try to delete all python related programmes and reinstall pylinac from scratch, though right now is a bad time.

Thanks for the support!

onsdag den 10. februar 2021 kl. 08.46.08 UTC+1 skrev Christian Storgaard:

Interesting. I think this is the impetus I need to use something like github actions to deploy versions to pypi instead of me doing it manually.