import yaml


def make_dataconfig(input_dir, sub, ses, anat, func, acquisition='alt+z', tr=2.0):
    """Generates the data_config file needed by cpac
    
    Arguments:
        input_dir {str} -- Path of directory containing input files
        sub {int} -- subject number
        ses {int} -- session number
        anat {str} -- Path of anatomical nifti file
        func {str} -- Path of functional nifti file
        acquisition {str} -- acquisition method for funcitonal scan
        tr {float} -- TR (seconds) of functional scan
    
    Returns:
        None
    """

    Data = [{
        'subject_id': sub,
        'unique_id': f'ses-{ses}',
        'anat': anat,
        'func': {
                'rest_run-1': {
			        'scan': func,
			        'scan_parameters': {
				    	'acquisition': acquisition,
				    	'tr': tr
			    }
		    }
	    }    
    }]
    
    config_file = f'{input_dir}/data_config.yaml'
    with open(config_file,'w',encoding='utf8') as outfile:
        yaml.dump(Data, outfile, default_flow_style=False)
    
    return config_file