Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NIFTI images (MRI, DTI, and PET) from ADNI database to jpg #23

Open
dupfem opened this issue Nov 7, 2022 · 1 comment
Open

NIFTI images (MRI, DTI, and PET) from ADNI database to jpg #23

dupfem opened this issue Nov 7, 2022 · 1 comment

Comments

@dupfem
Copy link

dupfem commented Nov 7, 2022

I have the dataset with four classes . I want to convert the NIFTI images to jpg to develop a model for classification

I am still debugging this segments of the code:
base_path=os.path.abspath(os.path.dirname(file))
parser = argparse.ArgumentParser(description='Arguments for input and output files')
parser.add_argument('--input_path', type=str, default = base_path, help='Path of the input files')
parser.add_argument('--rotation_angle', type=int, default = 90, help='Rotation degree, i.e., 90°, 180°, 270°, default value is 90°')
args = parser.parse_args()
input_path = args.input_path
rotation_angle = args.rotation_angle
##############################################################
#get list of nii or nii.gz source files
source_files = os.listdir(input_path)
slice_counter = 0
#identify sample ids and get source ids
source_ids = [files[0:8] for files in source_files if files.endswith('.nii')]

sample_ids = list(set(source_ids))

@monjoybme
Copy link
Contributor

Did you change .png to .jpg or .jpeg? Follow the below steps and run the code.
Replace: image_name = fname[:-4] + "_z" + "{:0>3}".format(str(current_slice+1))+ ".png"

with image_name = fname[:-4] + "_z" + "{:0>3}".format(str(current_slice+1))+ ".jpeg"

and
Replace: image_name = fname[:-4] + "_z" + "{:0>3}".format(str(current_slice+1))+ ".png"

with image_name = fname[:-4] + "_z" + "{:0>3}".format(str(current_slice+1))+ ".jpeg"

Let me know if it works for you. Else, you may share a single data for testing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants