import nibabel as nib
import numpy as np
import argparse

parser = argparse.ArgumentParser()
parser.add_argument(
    '--dir',
    type=str,
    default=r'D:\DATA\MRI_Datasets\ALS\1224993\test\t2',
    help='feature matrix directory')
parser.add_argument('--random_state',
                    type=int,
                    default=42,
                    help='seed for random initialisation')
args = parser.parse_args()
nii1 = nib.load(args.dir + '/t2_seg.nii.gz')
data1 = nii1.get_fdata()
nii2 = nib.load(args.dir + '/t2s_seg_t2.nii.gz')
data2 = nii2.get_fdata()
data = data1 + data2
threshold, upper, lower = 0.7, 1.0, 0.0
data = np.where(data > threshold, upper, lower)
niiNew = nib.Nifti1Image(data, nii1.affine)
nib.save(niiNew, args.dir + '/t2andt2s_seg.nii.gz')
