# Path: src/utils.py
# def splitext(s):
#     try :
#         ssplit = os.path.basename(s).split('.')
#         ext='.'+'.'.join(ssplit[1:])
#         basepath= re.sub(ext,'',s)
#         return [basepath, ext]
#     except TypeError :  
#         return s


import os
import numpy as np
import tempfile
import shutil
import json
import ntpath
import shutil
import nibabel as nib
import re
import nipype.pipeline.engine as pe
import nipype.interfaces.utility as niu
import nibabel as nib 
import numpy as np 
from nipype.interfaces.base import (TraitedSpec, File, traits, InputMultiPath,
        BaseInterface, OutputMultiPath, BaseInterfaceInputSpec, isdefined)
from nipype.utils.filemanip import (load_json, save_json, split_filename, fname_presuffix, copyfile)
from math import *
from time import gmtime, strftime
from glob import glob
from os.path import basename
from src.utils import splitext
from skimage.filters import threshold_otsu 
from scipy.ndimage import gaussian_filter 
            outputs["t1_ses"] = self.inputs.t1_ses
            print('hello')
        
        if isdefined(self.inputs.task):
            outputs["task"] = self.inputs.task

        if isdefined(self.inputs.run):
            outputs["run"] = self.inputs.run

        if isdefined(self.inputs.RoiSuffix):
            outputs["RoiSuffix"]= self.inputs.RoiSuffix
        return outputs

class pet3DVolumeOutput(TraitedSpec):
    out_file = File(desc="Image after centering")

class pet3DVolumeInput(BaseInterfaceInputSpec):
    in_file = File(position=0, argstr="%s", mandatory=True, desc="Image")
    out_file = File(argstr="%s", desc="Image after centering")
    verbose = traits.Int(argstr="-verbose", usedefault=True, default_value=True, desc="Write messages indicating progress")



class pet3DVolume(BaseInterface):
    input_spec = pet3DVolumeInput
    output_spec = pet3DVolumeOutput
    _suffix = "_3D"

    def _gen_output(self, basefile, _suffix):
        fname = ntpath.basename(basefile)

# Path: src/utils.py
# def splitext(s):
#     try :
#         ssplit = os.path.basename(s).split('.')
#         ext='.'+'.'.join(ssplit[1:])
#         basepath= re.sub(ext,'',s)
#         return [basepath, ext]
#     except TypeError :  
#         return s


# Path: src/initialization.py
import os
import numpy as np
import tempfile
import shutil
import json
import ntpath
import shutil
import nibabel as nib
import re
import nipype.pipeline.engine as pe
import nipype.interfaces.utility as niu
import nibabel as nib 
import numpy as np 
from nipype.interfaces.base import (TraitedSpec, File, traits, InputMultiPath,
        BaseInterface, OutputMultiPath, BaseInterfaceInputSpec, isdefined)
from nipype.utils.filemanip import (load_json, save_json, split_filename, fname_presuffix, copyfile)
from math import *
from time import gmtime, strftime
from glob import glob
from os.path import basename
from src.utils import splitext
from skimage.filters import threshold_otsu 
from scipy.ndimage import gaussian_filter 

            outputs["t1_ses"] = self.inputs.t1_ses
            print('hello')
        
        if isdefined(self.inputs.task):
            outputs["task"] = self.inputs.task

        if isdefined(self.inputs.run):
            outputs["run"] = self.inputs.run

        if isdefined(self.inputs.RoiSuffix):
            outputs["RoiSuffix"]= self.inputs.RoiSuffix
        return outputs

class pet3DVolumeOutput(TraitedSpec):
    out_file = File(desc="Image after centering")

class pet3DVolumeInput(BaseInterfaceInputSpec):
    in_file = File(position=0, argstr="%s", mandatory=True, desc="Image")
    out_file = File(argstr="%s", desc="Image after centering")
    verbose = traits.Int(argstr="-verbose", usedefault=True, default_value=True, desc="Write messages indicating progress")



class pet3DVolume(BaseInterface):
    input_spec = pet3DVolumeInput
    output_spec = pet3DVolumeOutput
    _suffix = "_3D"

    def _gen_output(self, basefile, _suffix):
        fname = ntpath.basename(basefile)

        fname_list = splitext(fname) # [0]= base filename; [1] =extension