@@ -685,7 +685,7 @@ def agg_data(self, intent_code=None):
685
685
In the general case, the numpy data array is extracted from each ``GiftiDataArray``
686
686
object and returned in a ``tuple``, in the order they are found in the GIFTI image.
687
687
688
- If all ``GiftiDataArray``s have ``intent`` of 2001 (``NIFTI_INTENT_TIME_SERIES``),
688
+ If all ``GiftiDataArray`` s have ``intent`` of 2001 (``NIFTI_INTENT_TIME_SERIES``),
689
689
then the data arrays are concatenated as columns, producing a vertex-by-time array.
690
690
If an ``intent_code`` is passed, data arrays are filtered by the selected intents,
691
691
before being aggregated.
@@ -695,7 +695,21 @@ def agg_data(self, intent_code=None):
695
695
``agg_data`` for each element, in order.
696
696
This may be useful for ensuring that expected data arrives in a consistent order.
697
697
698
- Examples:
698
+ Parameters
699
+ ----------
700
+ intent_code : None, string, integer or tuple of strings or integers, optional
701
+ code(s) specifying nifti intent
702
+
703
+ Returns
704
+ -------
705
+ tuple of ndarrays or ndarray
706
+ If the input is a tuple, the returned tuple will match the order.
707
+
708
+ Examples
709
+ --------
710
+
711
+ Load two kinds of Gifti files: a surface file containing two types of intent code;
712
+ a functional file storing time series data only.
699
713
700
714
>>> import nibabel as nib
701
715
>>> from nibabel.testing import test_data
@@ -704,85 +718,54 @@ def agg_data(self, intent_code=None):
704
718
>>> func_gii_fname = test_data('gifti', 'sub-01_task-rhymejudgment_space-xformspaceverage3_hemi-L.func.gii')
705
719
>>> func_gii_img = nib.load(func_gii_fname)
706
720
707
- When not passing anything to``intent_code``
721
+ When not passing anything to ``intent_code``
708
722
709
723
>>> surf_gii_img.agg_data() # surface file
710
724
(array([[-16.07201 , -66.187515, 21.266994],
711
725
[-16.705893, -66.05434 , 21.232786],
712
726
[-17.61435 , -65.40164 , 21.071466]], dtype=float32),
713
727
array([0, 1, 2], dtype=int32))
714
-
715
728
>>> func_gii_img.agg_data() # functional file
716
729
array([[545.4326 , 535.8471 , 537.5014 , ..., 540.2762 , 539.53827 ,
717
- 541.3617 ],
718
- [640.0118 , 634.727 , 630.03784 , ..., 635.21936 , 641.19586 ,
719
- 638.7647 ],
720
- [612.9056 , 607.3228 , 606.1355 , ..., 608.2441 , 615.8239 ,
721
- 613.0585 ],
722
- ...,
723
- [101.28482 , 101.41192 , 99.21213 , ..., 100.47232 , 99.258316,
724
- 99.440796],
725
- [371.81592 , 367.02896 , 363.90207 , ..., 365.52597 , 363.44937 ,
726
- 363.10278 ],
727
- [268.6521 , 262.0212 , 259.06717 , ..., 262.5381 , 257.8245 ,
730
+ ...,
731
+ [268.6521 , 262.0212 , 259.06717 , ..., 262.5381 , 257.8245 ,
728
732
259.7127 ]], dtype=float32)
729
733
730
-
731
734
When passig matching intend codes ``intent_code``
732
735
733
- >>> surf_gii_img.agg_data('pointset') # surface file
736
+ >>> surf_gii_img.agg_data('pointset') # surface pointset
734
737
array([[-16.07201 , -66.187515, 21.266994],
735
738
[-16.705893, -66.05434 , 21.232786],
736
739
[-17.61435 , -65.40164 , 21.071466]], dtype=float32)
737
-
740
+ >>> surf_gii_img.agg_data('triangle') # surface triangle
741
+ array([0, 1, 2], dtype=int32)
738
742
>>> func_gii_img.agg_data('time series') # functional file
739
743
array([[545.4326 , 535.8471 , 537.5014 , ..., 540.2762 , 539.53827 ,
740
744
541.3617 ],
741
- [640.0118 , 634.727 , 630.03784 , ..., 635.21936 , 641.19586 ,
742
- 638.7647 ],
743
- [612.9056 , 607.3228 , 606.1355 , ..., 608.2441 , 615.8239 ,
744
- 613.0585 ],
745
- ...,
746
- [101.28482 , 101.41192 , 99.21213 , ..., 100.47232 , 99.258316,
747
- 99.440796],
748
- [371.81592 , 367.02896 , 363.90207 , ..., 365.52597 , 363.44937 ,
749
- 363.10278 ],
750
- [268.6521 , 262.0212 , 259.06717 , ..., 262.5381 , 257.8245 ,
745
+ ...,
746
+ [268.6521 , 262.0212 , 259.06717 , ..., 262.5381 , 257.8245 ,
751
747
259.7127 ]], dtype=float32)
752
748
753
- >>> surf_gii_img.agg_data('triangle')
754
- array([0, 1, 2], dtype=int32)
755
749
756
- When passing mismatching intent codes ``intent_code ``
750
+ When passing mismatching ``intent_code``, the function return a empty ``tuple ``
757
751
758
752
>>> surf_gii_img.agg_data('time series')
759
- () # return a empty ``tuple``
760
-
753
+ ()
761
754
>>> func_gii_img.agg_data('triangle')
762
- () # return a empty ``tuple``
755
+ ()
763
756
764
- When passing tuple ``intent_code``
757
+ When passing tuple ``intent_code``, the output will follow
758
+ the order of ``intent_code`` in the tuple
765
759
766
760
>>> surf_gii_img.agg_data(('pointset', 'triangle'))
767
761
(array([[-16.07201 , -66.187515, 21.266994],
768
762
[-16.705893, -66.05434 , 21.232786],
769
763
[-17.61435 , -65.40164 , 21.071466]], dtype=float32),
770
764
array([0, 1, 2], dtype=int32))
771
-
772
765
>>> surf_gii_img.agg_data(('triangle', 'pointset'))
773
766
(array([0, 1, 2], dtype=int32), array([[-16.07201 , -66.187515, 21.266994],
774
767
[-16.705893, -66.05434 , 21.232786],
775
768
[-17.61435 , -65.40164 , 21.071466]], dtype=float32))
776
-
777
- Parameters
778
- ----------
779
- intent_code : None, string, integer or tuple of strings or integers, optional
780
- code(s) specifying nifti intent
781
-
782
- Returns
783
- -------
784
- tuple of ndarrays or ndarray
785
- If the input is a tuple, the returned tuple will match the order.
786
769
"""
787
770
788
771
# Allow multiple intents to specify the order
0 commit comments