from nipype.interfaces import afni

from nose.tools import assert_equal


def test_To3d():
    cmd = afni.To3d()
    yield assert_equal, cmd.cmdline, 'to3d'
    cmd = afni.To3d(anat=True)
    yield assert_equal, cmd.cmdline, 'to3d -anat'
    cmd = afni.To3d()
    cmd.inputs.datum = 'float'
    yield assert_equal, cmd.cmdline, 'to3d -datum float'
    cmd = afni.To3d()
    cmd.inputs.session = '/home/bobama'
    yield assert_equal, cmd.cmdline, 'to3d -session /home/bobama'
    cmd = afni.To3d(prefix='foo.nii.gz')
    yield assert_equal, cmd.cmdline, 'to3d -prefix foo.nii.gz'
    cmd = afni.To3d(infiles='/data/*.dcm')
    yield assert_equal, cmd.cmdline, 'to3d /data/*.dcm'
    cmd = afni.To3d(epan=True)
    yield assert_equal, cmd.cmdline, 'to3d -epan'
    cmd = afni.To3d(skip_outliers=True)
    yield assert_equal, cmd.cmdline, 'to3d -skip_outliers'
    cmd = afni.To3d(assume_dicom_mosaic=True)
    yield assert_equal, cmd.cmdline, 'to3d -assume_dicom_mosaic'
    # Test slice time params
    cmd = afni.To3d()
    cmd.inputs.time = ['zt', 12, 150, 2000, 'alt+z']
    yield assert_equal, cmd.cmdline, 'to3d -time:zt 12 150 2000.000000 alt+z'
    cmd = afni.To3d()
    cmd.inputs.time = ['tz', 150, 12, 2000, 'alt+z']
    yield assert_equal, cmd.cmdline, 'to3d -time:tz 150 12 2000.000000 alt+z'


@@ -150,16 +150,17 @@
  'to3d'%0A
+%0A
     cmd 
@@ -175,17 +175,23 @@
 o3d(
-anat=True
+datatype='anat'
 )%0A  
@@ -234,24 +234,112 @@
 to3d -anat'%0A
+    cmd = afni.To3d(datatype='epan')%0A    yield assert_equal, cmd.cmdline, 'to3d -epan'%0A%0A
     cmd = af
@@ -432,24 +432,25 @@
 atum float'%0A
+%0A
     cmd = af
@@ -561,24 +561,25 @@
 ome/bobama'%0A
+%0A
     cmd = af
@@ -670,16 +670,17 @@
 nii.gz'%0A
+%0A
     cmd 
@@ -774,88 +774,9 @@
 cm'%0A
-    cmd = afni.To3d(epan=True)%0A    yield assert_equal, cmd.cmdline, 'to3d -epan'
+%0A
 %0A   
@@ -871,16 +871,17 @@
 tliers'%0A
+%0A
     cmd 
@@ -983,16 +983,17 @@
 mosaic'%0A
+%0A
     # Te
@@ -1043,56 +1043,115 @@
     
-cmd.inputs.time = %5B
+td = dict(slice_order=
 'zt', 
+nz=
 12, 
+nt=
 150, 
+TR=
 2000, 
-'alt+z'%5D
+tpattern='alt+z')%0A    cmd.inputs.time_dependencies = td
 %0A   
@@ -1210,31 +1210,24 @@
 150 2000
-.000000
  alt+z'%0A
     cmd 
@@ -1218,16 +1218,17 @@
  alt+z'%0A
+%0A
     cmd 
@@ -1249,56 +1249,115 @@
     
-cmd.inputs.time = %5B
+td = dict(slice_order=
 'tz', 
+nt=
 150, 
+nz=
 12, 
+TR=
 2000, 
-'alt+z'%5D
+tpattern='alt+z')%0A    cmd.inputs.time_dependencies = td
 %0A   
@@ -1420,15 +1420,8 @@
 2000
-.000000
  alt

Fix afni tests