def check_integrity(self, param, type=None):
        """
        check integrity of each option type
        if type is provided, use type instead of self.type_value --> allow recursive integrity checking
        """

        type_option = self.type_value
        if type is not None:
            type_option = type

        if type_option in self.OPTION_TYPES:
            return self.checkStandardType(param, type)

        elif type_option == "image_nifti":
            return self.checkIfNifti(param)

        elif type_option == "file":
            return self.checkFile(param)

        elif type_option == "file_output":  # check if permission are required
            if not sct.check_write_permission(param):
                self.parser.usage.error("Error of writing permissions on file: "+param)
            return param

        elif type_option == "folder":
            return self.checkFolder(param)

        elif type_option == "folder_creation":
            return self.checkFolderCreation(param)

        elif type_option == "multiple_choice":
            """
            the choices are listed in example variable
            """
            if param not in self.example:
                self.parser.usage.error(self.name + " only takes " + self.parser.usage.print_list_with_brackets(self.example) + " as potential arguments.")
            return param

        elif isinstance(type_option, list):
            """
            This option is defined as a list delimited by a delimiter (that cannot be a space)
            For now, only one-layer list are available
            Examples:
            [[','],'int']
            [[':'],'coordinate']
            """
            delimiter = type_option[0][0]
            sub_type = type_option[1]
            param_splitted = param.split(delimiter)
            if len(param_splitted) != 0:
                # check if files are separated by space (if "*" was used)
                if not param_splitted[0].find(' ') == -1:
                    # if so, split and return list
                    param_splitted = param_splitted[0].split(' ')
                return list([self.check_integrity(val, sub_type) for val in param_splitted])
            else:
                self.parser.usage.error("ERROR: Option "+self.name+" must be correctly written. See usage.")

        else:
            # self.parser.usage.error("ERROR: Type of option \"" + str(self.type_value) +"\" is not supported by the parser.")
            sct.printv("WARNING : Option "+str(self.type_value)+" does not exist and will have no effect on the execution of the script", "warining")
            sct.printv("Type -h to see supported options", "warning")
dataset/ETHPy150Open neuropoly/spinalcordtoolbox/scripts/msct_parser.py/Option.check_integrity/original