def plot_regressors_as_RGB(self, fig1, gs, regressors, rsq, b, colors, brightness_scale=3):

        b_pos = b * (b > 0)  # Get positive beta values
        # Set up colorize function
        c = Colorize(cmap="indexed", scale=brightness_scale, flag_scale=1)

        for ii in xrange(0, len(regressors)):
            ax1 = fig1.add_subplot(gs[0, ii])
            c.colors = [colors[ii]]
            img = c.transform([b_pos[ii, :, :]], mask=rsq, background=self.reference, mixing=0.5)
            self.image(img)

        # Plot the unique stimuli in subplots
        subplot_count = 0
        for ii in self.unique_stimuli:
            b_pos_list = []
            color_mat = []
            for keys in regressors.iterkeys():
                if ii in keys:
                    index = regressors.keys().index(keys)
                    b_pos_list.append(b_pos[index, :, :])
                    color_mat.append(colors[index])
            ax1 = fig1.add_subplot(gs[1, subplot_count])
            c.colors = color_mat
            img = c.transform(b_pos_list, mask=rsq, background=self.reference, mixing=0.5)
            self.image(img)
            subplot_count += 1

        # Plot the different stimuli parameters in subplots
        for ii in self.parameters:
            b_pos_list = []
            color_mat = []
            for keys in regressors.iterkeys():
                if ii in keys:
                    index = regressors.keys().index(keys)
                    b_pos_list.append(b_pos[index, :, :])
                    color_mat.append(colors[index])
            ax1 = fig1.add_subplot(gs[1, subplot_count])
            c.colors = color_mat
            img = c.transform(b_pos_list, mask=rsq, background=self.reference, mixing=0.5)
            self.image(img)
            subplot_count += 1

        # Plot all together
        b_pos_list = []
        color_mat = []
        for ii in xrange(0, len(regressors)):
            b_pos_list.append(b_pos[ii, :, :])
            color_mat.append(colors[ii])
        ax1 = fig1.add_subplot(gs[2:4, 1:3])
        c.colors = color_mat
        img = c.transform(b_pos_list, mask=rsq, background=self.reference, mixing=0.5)
        self.image(img)
        subplot_count += 1

        ax1 = fig1.add_subplot(gs[2, 0])
        self.create_colorbar(ax1, regressors, colors)
    def plot_all_together_inseperateplot(self,
                                         fig1,
                                         gs,
                                         regressors,
                                         rsq,
                                         b,
                                         colors,
                                         brightness_scale=3,
                                         gridspecs='[0, 0]'):

        b_pos = b * (b > 0)  # Get positive beta values
        # Set up colorize function
        c = Colorize(cmap='indexed', scale=brightness_scale, flag_scale=1)

        b_pos_list = []
        color_mat = []
        for ii in xrange(0, len(regressors)):
            b_pos_list.append(b_pos[ii, :, :])
            color_mat.append(colors[ii])
        ax1 = eval('fig1.add_subplot(gs' + gridspecs + ')')
        c.colors = color_mat
        img = c.transform(b_pos_list,
                          mask=rsq,
                          background=self.reference,
                          mixing=0.5)
        self.image(img)
Esempio n. 3
0
    def masks(self, dims=None, binary=True, outline=False, base=None):
        """
        Composite masks combined across sources as an iamge.

        Parameters
        ----------
        dims : list or tuple, optional, default = None
            Dimensions of image in which to create masks, must either provide
            these or provide a base image

        binary : boolean, optional, deafult = True
            Whether to incoporate values or only show a binary mask

        outline : boolean, optional, deafult = False
            Whether to only show outlines (derived using binary dilation)

        base : array-like, optional, deafult = None
            Base background image on which to put masks.
        """
        from thunder import Colorize

        if dims is None and base is None:
            raise Exception(
                "Must provide image dimensions for composite masks "
                "or provide a base image.")

        if base is not None and isinstance(base, SourceModel):
            outline = True

        if dims is None and base is not None:
            dims = asarray(base).shape

        combined = zeros(dims)
        for s in self.sources:
            combined = maximum(s.mask(dims, binary, outline), combined)

        if base is not None:
            if isinstance(base, SourceModel):
                base = base.masks(dims)
                baseColor = 'silver'
            else:
                baseColor = 'white'
            clr = Colorize(cmap='indexed', colors=[baseColor, 'deeppink'])
            combined = clr.transform([base, combined])

        return combined
    def plot_all_together_inseperateplot(
        self, fig1, gs, regressors, rsq, b, colors, brightness_scale=3, gridspecs="[0, 0]"
    ):

        b_pos = b * (b > 0)  # Get positive beta values
        # Set up colorize function
        c = Colorize(cmap="indexed", scale=brightness_scale, flag_scale=1)

        b_pos_list = []
        color_mat = []
        for ii in xrange(0, len(regressors)):
            b_pos_list.append(b_pos[ii, :, :])
            color_mat.append(colors[ii])
        ax1 = eval("fig1.add_subplot(gs" + gridspecs + ")")
        c.colors = color_mat
        img = c.transform(b_pos_list, mask=rsq, background=self.reference, mixing=0.5)
        self.image(img)
Esempio n. 5
0
    def masks(self, dims=None, binary=True, outline=False, base=None):
        """
        Composite masks combined across sources as an iamge.

        Parameters
        ----------
        dims : list or tuple, optional, default = None
            Dimensions of image in which to create masks, must either provide
            these or provide a base image

        binary : boolean, optional, deafult = True
            Whether to incoporate values or only show a binary mask

        outline : boolean, optional, deafult = False
            Whether to only show outlines (derived using binary dilation)

        base : array-like, optional, deafult = None
            Base background image on which to put masks.
        """
        from thunder import Colorize

        if dims is None and base is None:
            raise Exception("Must provide image dimensions for composite masks "
                            "or provide a base image.")

        if base is not None and isinstance(base, SourceModel):
            outline = True

        if dims is None and base is not None:
            dims = asarray(base).shape

        combined = zeros(dims)
        for s in self.sources:
            combined = maximum(s.mask(dims, binary, outline), combined)

        if base is not None:
            if isinstance(base, SourceModel):
                base = base.masks(dims)
                baseColor = 'silver'
            else:
                baseColor = 'white'
            clr = Colorize(cmap='indexed', colors=[baseColor, 'deeppink'])
            combined = clr.transform([base, combined])

        return combined
    def plot_regressors_as_RGB(self,
                               fig1,
                               gs,
                               regressors,
                               rsq,
                               b,
                               colors,
                               brightness_scale=3):

        b_pos = b * (b > 0)  # Get positive beta values
        # Set up colorize function
        c = Colorize(cmap='indexed', scale=brightness_scale, flag_scale=1)

        for ii in xrange(0, len(regressors)):
            ax1 = fig1.add_subplot(gs[0, ii])
            c.colors = [colors[ii]]
            img = c.transform([b_pos[ii, :, :]],
                              mask=rsq,
                              background=self.reference,
                              mixing=0.5)
            self.image(img)

        # Plot the unique stimuli in subplots
        subplot_count = 0
        for ii in self.unique_stimuli:
            b_pos_list = []
            color_mat = []
            for keys in regressors.iterkeys():
                if ii in keys:
                    index = regressors.keys().index(keys)
                    b_pos_list.append(b_pos[index, :, :])
                    color_mat.append(colors[index])
            ax1 = fig1.add_subplot(gs[1, subplot_count])
            c.colors = color_mat
            img = c.transform(b_pos_list,
                              mask=rsq,
                              background=self.reference,
                              mixing=0.5)
            self.image(img)
            subplot_count += 1

        # Plot the different stimuli parameters in subplots
        for ii in self.parameters:
            b_pos_list = []
            color_mat = []
            for keys in regressors.iterkeys():
                if ii in keys:
                    index = regressors.keys().index(keys)
                    b_pos_list.append(b_pos[index, :, :])
                    color_mat.append(colors[index])
            ax1 = fig1.add_subplot(gs[1, subplot_count])
            c.colors = color_mat
            img = c.transform(b_pos_list,
                              mask=rsq,
                              background=self.reference,
                              mixing=0.5)
            self.image(img)
            subplot_count += 1

        # Plot all together
        b_pos_list = []
        color_mat = []
        for ii in xrange(0, len(regressors)):
            b_pos_list.append(b_pos[ii, :, :])
            color_mat.append(colors[ii])
        ax1 = fig1.add_subplot(gs[2:4, 1:3])
        c.colors = color_mat
        img = c.transform(b_pos_list,
                          mask=rsq,
                          background=self.reference,
                          mixing=0.5)
        self.image(img)
        subplot_count += 1

        ax1 = fig1.add_subplot(gs[2, 0])
        self.create_colorbar(ax1, regressors, colors)