Module Expr Str Import alias Import alias identifier ImportFrom alias ImportFrom alias alias ImportFrom alias ImportFrom alias ImportFrom alias ImportFrom alias Assign NameStore SubscriptLoad Call NameLoad Str Index Num Expr Str Assign NameStore AttributeLoad NameLoad attr Assign NameStore SubscriptLoad AttributeLoad NameLoad attr Slice Assign SubscriptStore NameLoad Index Call AttributeLoad NameLoad attr TupleLoad Str Str TupleLoad Str Str Assign NameStore SubscriptLoad AttributeLoad NameLoad attr Slice Assign SubscriptStore NameLoad Index Call AttributeLoad NameLoad attr TupleLoad Str Str TupleLoad Str Str TupleLoad Num Assign NameStore Call AttributeLoad NameLoad attr BinOpAdd BinOpAdd NameLoad NameLoad NameLoad ClassDef bases AttributeLoad NameLoad attr body Expr Str Assign NameStore NameLoad Assign NameStore NameLoad Assign NameStore NameLoad FunctionDef arguments args NameParam NameParam defaults NameLoad body Expr Str Assign NameStore Call AttributeLoad Call NameLoad NameLoad NameLoad attr NameLoad Assign SubscriptStore NameLoad Index Str Num Return NameLoad decorator_list NameLoad FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore SubscriptLoad AttributeLoad NameLoad attr Index Str If BoolOpOr Call AttributeLoad NameLoad attr NameLoad CompareIn NameLoad TupleLoad Num UnaryOpUSub AttributeLoad NameLoad attr AttributeLoad NameLoad attr body Return TupleLoad NameLoad NameLoad Return TupleLoad NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults NameLoad body Expr Str If CompareIs NameLoad NameLoad body Assign NameStore AttributeLoad NameLoad attr If CompareIn NameLoad TupleLoad Num UnaryOpUSub AttributeLoad NameLoad attr AttributeLoad NameLoad attr body Raise Call NameLoad Str Assign SubscriptStore AttributeLoad NameLoad attr Index Str NameLoad If BoolOpOr CompareIn NameLoad TupleLoad NameLoad Num Call AttributeLoad NameLoad attr NameLoad body Return Raise Call NameLoad Str decorator_list decorator_list ClassDef bases NameLoad body Expr Str FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad SubscriptLoad SubscriptLoad NameLoad Index Str Slice Num Num attr If AttributeLoad NameLoad attr body AugAssignMult SubscriptStore NameLoad Index Num Num Assign NameStore SubscriptLoad SubscriptLoad NameLoad Index Str Slice Num Assign NameStore SubscriptLoad SubscriptLoad NameLoad Index Str Slice Num Num If BoolOpAnd Call AttributeLoad NameLoad attr NameLoad Call AttributeLoad NameLoad attr CompareGt NameLoad UnaryOpUSub NameLoad Call AttributeLoad NameLoad attr CompareLt NameLoad BinOpMult NameLoad Num body Assign NameStore BinOpSub NameLoad Num orelse Assign NameStore BinOpDiv BinOpSub NameLoad Num Num Assign NameStore Call AttributeLoad NameLoad attr Num Assign SubscriptStore NameLoad ExtSlice Slice Num Slice Num Call AttributeLoad NameLoad attr NameLoad Assign SubscriptStore NameLoad ExtSlice Slice Num Index Num BinOpMult UnaryOpUSub NameLoad NameLoad Return NameLoad decorator_list Assign NameStore NameLoad FunctionDef arguments args NameParam NameParam defaults body Expr Str If CompareNotEq AttributeLoad NameLoad attr TupleLoad Num Num body Raise Call NameLoad Str Assign NameStore AttributeLoad NameLoad attr Assign NameStore SubscriptLoad NameLoad ExtSlice Slice Num Slice Num Assign NameStore Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr BinOpMult NameLoad NameLoad keyword Num Assign NameStore SubscriptLoad NameLoad ExtSlice Slice Num Index Num Assign SubscriptStore SubscriptLoad NameLoad Index Str Slice Num BinOpAdd BinOpDiv UnaryOpUSub NameLoad NameLoad Num decorator_list FunctionDef arguments args NameParam defaults body Assign NameStore Call AttributeLoad Call NameLoad NameLoad NameLoad attr Return BinOpAdd NameLoad TupleLoad AttributeLoad NameLoad attr decorator_list NameLoad FunctionDef arguments args NameParam NameParam defaults NameLoad body Assign NameStore Call NameLoad NameLoad Assign NameStore SubscriptLoad SubscriptLoad NameLoad Index Str Slice Num Num Assign NameStore SubscriptLoad SubscriptLoad NameLoad Index Str Slice Num Num If BoolOpOr UnaryOpNot Call AttributeLoad NameLoad attr NameLoad BoolOpAnd Call AttributeLoad NameLoad attr CompareGt NameLoad UnaryOpUSub NameLoad Call AttributeLoad NameLoad attr CompareLt NameLoad BinOpMult NameLoad Num body Return TupleLoad NameLoad NameLoad Assign AttributeStore NameLoad attr Num Assign AttributeStore NameLoad attr Str If NameLoad body Assign AttributeStore NameLoad attr Str Return TupleLoad NameLoad NameLoad decorator_list NameLoad decorator_list ClassDef bases AttributeLoad NameLoad attr body Expr Str Assign NameStore NameLoad Assign NameStore TupleLoad TupleLoad Str Str TupleLoad Str Str TupleLoad Str Str Assign NameStore NameLoad Assign NameStore NameLoad Assign NameStore NameLoad FunctionDef arguments args NameParam NameParam NameParam defaults NameLoad body Expr Str Assign NameStore Call AttributeLoad Call NameLoad NameLoad NameLoad attr NameLoad keyword NameLoad TryExcept body Assign NameStore Call AttributeLoad SubscriptLoad NameLoad Index Str attr handlers ExceptHandler type NameLoad body Return NameLoad With NameLoad body Assign NameStore Call AttributeLoad NameLoad attr If CompareEq Call NameLoad NameLoad Num body Return NameLoad Import alias identifier Assign NameStore Call AttributeLoad NameLoad attr Call NameLoad NameLoad If CompareIn Str NameLoad body Assign NameStore SubscriptLoad NameLoad Index Str If CompareGt AttributeLoad NameLoad attr Num body Expr Call AttributeLoad NameLoad attr Str Assign NameStore SubscriptLoad NameLoad ExtSlice Slice Slice Index Num Assign AttributeStore NameLoad attr NameLoad orelse If CompareIn Str NameLoad body Assign NameStore AttributeLoad NameLoad attr If AttributeLoad NameLoad attr body Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr ListLoad Num Num Num Num SubscriptLoad NameLoad Index Str orelse Assign AttributeStore NameLoad attr SubscriptLoad NameLoad Index Str orelse Raise Call NameLoad Str Assign NameStore Call AttributeLoad NameLoad attr Num Assign SubscriptStore NameLoad ExtSlice Slice Num Index Num Num Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr NameLoad Return NameLoad decorator_list NameLoad Call NameLoad Num FunctionDef arguments args NameParam NameParam defaults NameLoad body Expr Str If CompareIs NameLoad NameLoad body Assign NameStore AttributeLoad NameLoad attr Expr Call AttributeLoad Call NameLoad NameLoad NameLoad attr NameLoad Assign NameStore AttributeLoad NameLoad attr If CompareIs NameLoad NameLoad body Return Import alias identifier Assign NameStore AttributeLoad NameLoad attr If AttributeLoad NameLoad attr body Assign NameStore Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr ListLoad Num Num Num Num NameLoad orelse Assign NameStore NameLoad Assign NameStore Call AttributeLoad NameLoad attr Num Assign SubscriptStore NameLoad ExtSlice Slice Num Index Num Num Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad With Call AttributeLoad SubscriptLoad NameLoad Index Str attr keyword Str NameStore body Expr Call AttributeLoad NameLoad attr NameLoad Dict Str Str NameLoad NameLoad keyword Str decorator_list decorator_list Assign NameStore AttributeLoad NameLoad attr Assign NameStore AttributeLoad NameLoad attr
N/A N/A  Read / write access to SPM99 version of analyze image format  N/A warnings N/A numpy np externals.six BytesIO spatialimages HeaderDataError HeaderTypeError batteryrunners Report N/A analyze keywordonly kw_only_meth optpkg optional_package N/A have_scipy N/A N/A optional_package scipy N/A 1 N/A  Support subtle variations of SPM version of Analyze  N/A header_key_dtd N/A analyze header_key_dtd N/A image_dimension_dtd N/A N/A analyze image_dimension_dtd N/A N/A N/A image_dimension_dtd N/A N/A N/A image_dimension_dtd index N/A funused1 f4 N/A scl_slope f4 N/A data_history_dtd N/A N/A analyze data_history_dtd N/A N/A N/A data_history_dtd N/A N/A N/A data_history_dtd index N/A originator S10 N/A origin i2 N/A 5 N/A header_dtype N/A N/A np dtype N/A N/A header_key_dtd image_dimension_dtd data_history_dtd SpmAnalyzeHeader N/A N/A analyze AnalyzeHeader N/A N/A  Basic scaling Spm Analyze header  N/A template_dtype header_dtype N/A has_data_slope True N/A has_data_intercept False default_structarr N/A N/A klass endianness N/A None N/A N/A  Create empty header binary block with given endianness  N/A hdr_data N/A N/A N/A super SpmAnalyzeHeader klass default_structarr endianness N/A N/A hdr_data N/A scl_slope 1 N/A hdr_data N/A classmethod get_slope_inter N/A N/A self N/A N/A N/A  Get scalefactor and intercept

        If scalefactor is 0.0 return None to indicate no scalefactor.
        Intercept is always None because SPM99 analyze cannot store intercepts.
         N/A slope N/A N/A self _structarr N/A scl_slope N/A N/A N/A N/A np isnan slope N/A slope N/A 0 N/A N/A np inf N/A np inf N/A N/A N/A None None N/A N/A slope None N/A set_slope_inter N/A N/A self slope inter N/A None N/A N/A  Set slope and / or intercept into header

        Set slope and intercept for image data, such that, if the image
        data is ``arr``, then the scaled image data will be ``(arr *
        slope) + inter``

        The SPM Analyze header can't save an intercept value, and we raise an
        error unless `inter` is None, NaN or 0

        Parameters
        ----------
        slope : None or float
           If None, implies `slope` of NaN.  NaN is a signal to the image
           writing routines to rescale on save.  0, Inf, -Inf are invalid and
           cause a HeaderDataError
        inter : None or float, optional
           intercept. Must be None, NaN or 0, because SPM99 cannot store
           intercepts.
         N/A N/A slope None N/A N/A slope N/A np nan N/A N/A slope N/A 0 N/A N/A np inf N/A np inf N/A N/A N/A HeaderDataError Slope cannot be 0 or infinite N/A N/A N/A self _structarr N/A scl_slope slope N/A N/A N/A inter N/A None 0 N/A N/A np isnan inter N/A N/A N/A N/A HeaderTypeError Cannot set non-zero intercept for SPM headers N/A N/A Spm99AnalyzeHeader N/A SpmAnalyzeHeader N/A N/A  Class for SPM99 variant of basic Analyze header

    SPM99 variant adds the following to basic Analyze format:

    * voxel origin;
    * slope scaling of data.
     get_origin_affine N/A N/A self N/A N/A N/A  Get affine from header, using SPM origin field if sensible

        The default translations are got from the ``origin``
        field, if set, or from the center of the image otherwise.

        Examples
        --------
        >>> hdr = Spm99AnalyzeHeader()
        >>> hdr.set_data_shape((3, 5, 7))
        >>> hdr.set_zooms((3, 2, 1))
        >>> hdr.default_x_flip
        True
        >>> hdr.get_origin_affine() # from center of image
        array([[-3.,  0.,  0.,  3.],
               [ 0.,  2.,  0., -4.],
               [ 0.,  0.,  1., -3.],
               [ 0.,  0.,  0.,  1.]])
        >>> hdr['origin'][:3] = [3,4,5]
        >>> hdr.get_origin_affine() # using origin
        array([[-3.,  0.,  0.,  6.],
               [ 0.,  2.,  0., -6.],
               [ 0.,  0.,  1., -4.],
               [ 0.,  0.,  0.,  1.]])
        >>> hdr['origin'] = 0 # unset origin
        >>> hdr.set_data_shape((3, 5, 7))
        >>> hdr.get_origin_affine() # from center of image
        array([[-3.,  0.,  0.,  3.],
               [ 0.,  2.,  0., -4.],
               [ 0.,  0.,  1., -3.],
               [ 0.,  0.,  0.,  1.]])
         N/A hdr N/A self _structarr N/A zooms N/A N/A N/A N/A hdr N/A pixdim N/A 1 4 copy N/A N/A self default_x_flip N/A N/A N/A zooms N/A 0 -1 N/A origin N/A N/A hdr N/A origin N/A 3 N/A dims N/A N/A hdr N/A dim N/A 1 4 N/A N/A N/A N/A np any origin N/A N/A np all N/A origin N/A dims N/A N/A np all N/A origin N/A dims 2 N/A N/A origin N/A origin 1 N/A N/A origin N/A N/A dims 1 2.0 N/A aff N/A N/A np eye 4 N/A N/A aff N/A N/A 3 N/A 3 N/A N/A np diag zooms N/A N/A aff N/A N/A 3 N/A -1 N/A N/A origin zooms N/A aff N/A N/A get_best_affine get_origin_affine set_origin_from_affine N/A N/A self affine N/A N/A N/A  Set SPM origin to header from affine matrix.

        The ``origin`` field was read but not written by SPM99 and 2.  It was
        used for storing a central voxel coordinate, that could be used in
        aligning the image to some standard position - a proxy for a full
        translation vector that was usually stored in a separate matlab .mat
        file.

        Nifti uses the space occupied by the SPM ``origin`` field for important
        other information (the transform codes), so writing the origin will
        make the header a confusing Nifti file.  If you work with both Analyze
        and Nifti, you should probably avoid doing this.

        Parameters
        ----------
        affine : array-like, shape (4,4)
           Affine matrix to set

        Returns
        -------
        None

        Examples
        --------
        >>> hdr = Spm99AnalyzeHeader()
        >>> hdr.set_data_shape((3, 5, 7))
        >>> hdr.set_zooms((3,2,1))
        >>> hdr.get_origin_affine()
        array([[-3.,  0.,  0.,  3.],
               [ 0.,  2.,  0., -4.],
               [ 0.,  0.,  1., -3.],
               [ 0.,  0.,  0.,  1.]])
        >>> affine = np.diag([3,2,1,1])
        >>> affine[:3,3] = [-6, -6, -4]
        >>> hdr.set_origin_from_affine(affine)
        >>> np.all(hdr['origin'][:3] == [3,4,5])
        True
        >>> hdr.get_origin_affine()
        array([[-3.,  0.,  0.,  6.],
               [ 0.,  2.,  0., -6.],
               [ 0.,  0.,  1., -4.],
               [ 0.,  0.,  0.,  1.]])
         N/A N/A N/A affine shape N/A 4 4 N/A N/A N/A ValueError Need 4x4 affine to set N/A hdr N/A self _structarr N/A RZS N/A affine N/A N/A 3 N/A 3 N/A Z N/A N/A np sqrt N/A N/A np sum N/A RZS RZS axis 0 N/A T N/A affine N/A N/A 3 N/A 3 N/A N/A N/A hdr N/A origin N/A 3 N/A N/A N/A T Z 1 N/A _get_checks N/A N/A klass N/A N/A N/A checks N/A N/A N/A super Spm99AnalyzeHeader klass _get_checks N/A N/A checks N/A N/A klass _chk_origin N/A classmethod _chk_origin N/A N/A hdr fix N/A False N/A N/A rep N/A Report HeaderDataError N/A origin N/A N/A hdr N/A origin N/A 0 3 N/A dims N/A N/A hdr N/A dim N/A 1 4 N/A N/A N/A N/A N/A np any origin N/A N/A N/A np all N/A origin N/A dims N/A N/A np all N/A origin N/A dims 2 N/A N/A N/A hdr rep N/A N/A rep problem_level 20 N/A N/A rep problem_msg very large origin values relative to dims N/A fix N/A N/A N/A rep fix_msg leaving as set, ignoring for affine N/A N/A hdr rep N/A staticmethod N/A Spm99AnalyzeImage N/A N/A analyze AnalyzeImage N/A N/A  Class for SPM99 variant of basic Analyze image
     N/A header_class Spm99AnalyzeHeader N/A files_types N/A N/A image .img N/A header .hdr N/A mat .mat N/A has_affine True N/A makeable True N/A rw have_scipy from_file_map N/A N/A klass file_map mmap N/A True N/A N/A  class method to create image from mapping in `file_map ``

        Parameters
        ----------
        file_map : dict
            Mapping with (kay, value) pairs of (``file_type``, FileHolder
            instance giving file-likes for each file needed for this image
            type.
        mmap : {True, False, 'c', 'r'}, optional, keyword only
            `mmap` controls the use of numpy memory mapping for reading image
            array data.  If False, do not try numpy ``memmap`` for data array.
            If one of {'c', 'r'}, try numpy memmap with ``mode=mmap``.  A
            `mmap` value of True gives the same behavior as ``mmap='c'``.  If
            image data file cannot be memory-mapped, ignore `mmap` value and
            read array from file.

        Returns
        -------
        img : Spm99AnalyzeImage instance
         N/A ret N/A N/A N/A super Spm99AnalyzeImage klass from_file_map file_map mmap mmap N/A N/A N/A matf N/A N/A N/A file_map N/A mat get_prepare_fileobj N/A N/A N/A IOError N/A N/A ret N/A matf N/A N/A contents N/A N/A matf read N/A N/A N/A len contents 0 N/A N/A ret N/A scipy.io sio N/A mats N/A N/A sio loadmat N/A BytesIO contents N/A N/A mat mats N/A N/A mat N/A mats N/A mat N/A N/A N/A mat ndim 2 N/A N/A N/A N/A warnings warn More than one affine in "mat" matrix, using first N/A mat N/A mat N/A N/A N/A N/A 0 N/A N/A ret _affine mat N/A N/A N/A M mats N/A N/A hdr N/A ret _header N/A N/A hdr default_x_flip N/A N/A N/A ret _affine N/A N/A np dot N/A N/A np diag N/A -1 1 1 1 N/A mats N/A M N/A N/A N/A ret _affine N/A mats N/A M N/A N/A N/A ValueError mat file found but no "mat" or "M" in it N/A to_111 N/A N/A np eye 4 N/A N/A to_111 N/A N/A 3 N/A 3 1 N/A N/A ret _affine N/A N/A np dot N/A ret _affine to_111 N/A ret N/A classmethod N/A kw_only_meth 1 to_file_map N/A N/A self file_map N/A None N/A N/A  Write image to `file_map` or contained ``self.file_map``

        Extends Analyze ``to_file_map`` method by writing ``mat`` file

        Parameters
        ----------
        file_map : None or mapping, optional
           files mapping.  If None (default) use object's ``file_map``
           attribute instead
         N/A N/A file_map None N/A N/A file_map N/A self file_map N/A N/A N/A N/A super Spm99AnalyzeImage self to_file_map file_map N/A mat N/A self _affine N/A N/A mat None N/A N/A N/A scipy.io sio N/A hdr N/A self _header N/A N/A hdr default_x_flip N/A N/A M N/A N/A np dot N/A N/A np diag N/A -1 1 1 1 mat N/A N/A M mat N/A from_111 N/A N/A np eye 4 N/A N/A from_111 N/A N/A 3 N/A 3 -1 N/A M N/A N/A np dot M from_111 N/A mat N/A N/A np dot mat from_111 N/A N/A N/A N/A file_map N/A mat get_prepare_fileobj mode wb mfobj N/A N/A N/A N/A sio savemat mfobj N/A M mat M mat format 4 N/A N/A N/A load N/A Spm99AnalyzeImage load N/A save N/A Spm99AnalyzeImage instance_to_filename