pycortex icon indicating copy to clipboard operation
pycortex copied to clipboard

Saving composite as .svg

Open drorcohengithub opened this issue 6 years ago • 0 comments

Hi guys,

How would I got about saving a figure generated using composting as svg ?

Below I try savefig() but it saves the layers (here ROI labels and borders) as images, so editing in an svg editor later (for example changing color/thickness/size of ROI borders or labels) is not possible. The colorbar is saved as a separate layer which can be edited.

Without compositing, I can use make_svg(), which saves the ROIs (labels and borders) as paths(?) in a layer, so they are still editable. I don't think make_svg() supports composting since it requires braindata as the input (doesn't work with a figure already plotted).

I use composting for the ROIs but also to hilight a specific voxels (for example in seed-based analysis) and sometimes to separately plot different parts of the data (using composite.add_data()).

Cheers

import cortex
import matplotlib.pyplot as plt
import numpy as np

# Create a random volume
volume = cortex.Volume.random(subject='S1', xfmname='fullhead')

# Create basic figure, with rois, labels, sulci all off
fig = cortex.quickflat.make_figure(volume,
                                   with_curvature=True,
                                   with_rois=False,
                                   with_labels=False,
                                   with_sulci=False)
# Add sulci in light yellow
_ = cortex.quickflat.composite.add_sulci(fig, volume,
                                         with_labels=False,
                                         linewidth=2,
                                         linecolor=(0.9, 0.85, 0.5))
# Add all rois, with a particular color scheme:
_ = cortex.quickflat.composite.add_rois(fig, volume,
                                        with_labels=False,
                                        linewidth=1,
                                        linecolor=(0.8, 0.8, 0.8))
# Highlight face- and body-selective ROIs:
_ = cortex.quickflat.composite.add_rois(fig, volume,
                                        roi_list=['FFA', 'EBA', 'OFA'],  # (This defaults to all rois if not specified)
                                        with_labels=True,
                                        linewidth=5,
                                        linecolor=(0.9, 0.5, 0.5),
                                        roifill=(0.9, 0.5, 0.5),
                                        fillalpha=0.35,
                                        dashes=(5, 3)                    # Dash length & gap btw dashes
                                        )
plt.savefig('chk.svg',format = 'svg')
plt.imshow() 

drorcohengithub avatar Jun 12 '19 03:06 drorcohengithub