Cannot import name: scipy.misc.imresize

706 views
Skip to first unread message

Christian Storgaard

unread,
Feb 8, 2021, 7:05:07 AM2/8/21
to Pylinac
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


Andrea Girardi

unread,
Feb 8, 2021, 7:12:04 AM2/8/21
to Christian Storgaard, Pylinac

--
You received this message because you are subscribed to the Google Groups "Pylinac" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pylinac+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pylinac/1ffc9938-583b-46d5-8099-a9a5360d2796n%40googlegroups.com.


--
Andrea Girardi

             

James Kerns

unread,
Feb 9, 2021, 8:54:54 AM2/9/21
to Pylinac
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)  

Christian Storgaard

unread,
Feb 10, 2021, 2:46:08 AM2/10/21
to Pylinac
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.


Christian Storgaard

unread,
Feb 10, 2021, 8:42:08 AM2/10/21
to Pylinac
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!

James Kerns

unread,
Feb 10, 2021, 6:01:05 PM2/10/21
to Pylinac
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. 
Reply all
Reply to author
Forward
0 new messages