Demo entry 6717701

search corresponding source nii files

   

Submitted by Zhenjie Huang on Feb 27, 2018 at 19:18
Language: Python 3. Code size: 623 Bytes.

import os  
import shutil
import re
file_path_name=[]
file_number=[]
for (dirpath, dirnames, filenames) in os.walk(r'D:\ADNI600picked\7'):  
    for filename in filenames:  
        file_path_name.append(os.path.join(dirpath, filename))
#print(file_path_name)

fp=open(r'C:\Users\zhuan117\Desktop\me\day_7_602to631\subjects602to631.txt', 'r')
for line in fp.readlines():
    line=line.strip('\n')
    file_number.append(line)
fp.close()
#print(file_number)

for x in file_path_name:
    for y in file_number:
        if(x.endswith(y+'.nii')):
            shutil.copy(x,r'D:\ADNI600picked\day7(602-631)')

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).