@@ -1569,6 +1569,26 @@ def set_data_time_index(self, time_idx):
1569
1569
self .update_text (data ["time_label" ] % time , "time_label" )
1570
1570
self ._toggle_render (True , views )
1571
1571
1572
+ def get_data_time_index (self ):
1573
+ """Retrieve the currently displayed data time index
1574
+
1575
+ Returns
1576
+ -------
1577
+ time_idx : int
1578
+ Current time index.
1579
+
1580
+ Notes
1581
+ -----
1582
+ Raises a RuntimeError if the Brain instance has not data overlay.
1583
+ """
1584
+ time_idx = None
1585
+ for hemi in ['lh' , 'rh' ]:
1586
+ data = self .data_dict [hemi ]
1587
+ if data is not None :
1588
+ time_idx = data ["time_idx" ]
1589
+ return time_idx
1590
+ raise RuntimeError ("Brain instance has no data overlay" )
1591
+
1572
1592
@verbose
1573
1593
def set_data_smoothing_steps (self , smoothing_steps , verbose = None ):
1574
1594
"""Set the number of smoothing steps
@@ -1879,7 +1899,8 @@ def save_imageset(self, prefix, views, filetype='png', colorbar='auto',
1879
1899
return images_written
1880
1900
1881
1901
def save_image_sequence (self , time_idx , fname_pattern , use_abs_idx = True ,
1882
- row = - 1 , col = - 1 ):
1902
+ row = - 1 , col = - 1 , montage = 'single' , orientation = 'h' ,
1903
+ border_size = 15 , colorbar = 'auto' ):
1883
1904
"""Save a temporal image sequence
1884
1905
1885
1906
The files saved are named "fname_pattern % (pos)" where "pos" is a
@@ -1888,30 +1909,50 @@ def save_image_sequence(self, time_idx, fname_pattern, use_abs_idx=True,
1888
1909
Parameters
1889
1910
----------
1890
1911
time_idx : array-like
1891
- time indices to save
1912
+ Time indices to save.
1892
1913
fname_pattern : str
1893
- filename pattern, e.g. 'movie-frame_%0.4d.png'
1914
+ Filename pattern, e.g. 'movie-frame_%0.4d.png'.
1894
1915
use_abs_idx : boolean
1895
- if True the indices given by "time_idx" are used in the filename
1916
+ If True the indices given by "time_idx" are used in the filename
1896
1917
if False the index in the filename starts at zero and is
1897
- incremented by one for each image (Default: True)
1918
+ incremented by one for each image (Default: True).
1898
1919
row : int
1899
- row index of the brain to use
1920
+ Row index of the brain to use.
1900
1921
col : int
1901
- column index of the brain to use
1922
+ Column index of the brain to use.
1923
+ montage: 'current' | 'single' | list
1924
+ Views to include in the images: 'current' uses the currently
1925
+ displayed image; 'single' (default) uses a single view, specified
1926
+ by the ``row`` and ``col`` parameters; a list can be used to
1927
+ specify a complete montage (see :meth:`save_montage`).
1928
+ orientation: {'h' | 'v'}
1929
+ Montage image orientation (horizontal of vertical alignment; only
1930
+ applies if ``montage`` is a flat list).
1931
+ border_size: int
1932
+ Size of image border (more or less space between images).
1933
+ colorbar: None | 'auto' | [int], optional
1934
+ If None no colorbar is visible. If 'auto' is given the colorbar
1935
+ is only shown in the middle view. Otherwise on the listed
1936
+ views when a list of int is passed.
1902
1937
1903
1938
Returns
1904
1939
-------
1905
1940
images_written: list
1906
1941
all filenames written
1907
1942
"""
1908
- current_time_idx = self .data [ "time_idx" ]
1943
+ current_time_idx = self .get_data_time_index ()
1909
1944
images_written = list ()
1910
1945
rel_pos = 0
1911
1946
for idx in time_idx :
1912
1947
self .set_data_time_index (idx )
1913
1948
fname = fname_pattern % (idx if use_abs_idx else rel_pos )
1914
- self .save_single_image (fname , row , col )
1949
+ if montage == 'single' :
1950
+ self .save_single_image (fname , row , col )
1951
+ elif montage == 'current' :
1952
+ self .save_image (fname )
1953
+ else :
1954
+ self .save_montage (fname , montage , orientation , border_size ,
1955
+ colorbar , row , col )
1915
1956
images_written .append (fname )
1916
1957
rel_pos += 1
1917
1958
0 commit comments