Scheduled service maintenance on November 22


On Friday, November 22, 2024, between 06:00 CET and 18:00 CET, GIN services will undergo planned maintenance. Extended service interruptions should be expected. We will try to keep downtimes to a minimum, but recommend that users avoid critical tasks, large data uploads, or DOI requests during this time.

We apologize for any inconvenience.

download_sample.py 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. # Demo 1-1. Setting an enviroment
  2. from os import listdir, mkdir, path, system, getcwd
  3. dir_origin = dir_origin = getcwd()+'/' # <- Change this in local machine
  4. dir_dataset= 'dataset/'
  5. print('\n1============ Start Downloading =================\n')
  6. print('Target directory ... => [%s%s]'%(dir_origin,dir_dataset))
  7. #!rm -rf /content/dataset/
  8. import requests
  9. def download( dataset_to_download = range(1,7), dir_dataset = dir_dataset ):
  10. # Check directory
  11. if not path.isdir('%s%s'%(dir_origin,dir_dataset)):
  12. mkdir('%s%s'%(dir_origin,dir_dataset))
  13. mkdir('%s%s/rawdata/'%(dir_origin,dir_dataset))
  14. # File names to be downloaded
  15. file_ids = [ 'meta.csv', 'montage.csv' ]
  16. for set_id in dataset_to_download:
  17. file_ids.append( 'rawdata/epochs_animal%s.set'%set_id )
  18. file_ids.append( 'rawdata/epochs_animal%s.fdt'%set_id )
  19. # Request & download
  20. repo_url = 'https://gin.g-node.org/hiobeen/Mouse_hdEEG_ASSR_Hwang_et_al/raw/9a35f6b1a53f87a96d76b8b7912738cb7d8d3d36/'
  21. for file_id in file_ids:
  22. fname_dest = "%s%s%s"%(dir_origin, dir_dataset, file_id)
  23. if path.isfile(fname_dest) is False:
  24. print('...copying to [%s]...'%fname_dest)
  25. file_url = '%s%s'%(repo_url, file_id)
  26. r = requests.get(file_url, stream = True)
  27. with open(fname_dest, "wb") as file:
  28. for block in r.iter_content(chunk_size=1024):
  29. if block: file.write(block)
  30. else:
  31. print('...skipping already existing file [%s]...'%fname_dest)
  32. # Initiate downloading
  33. dataset_to_download = [2] # Partial download to prevent long download time
  34. #dataset_to_download = [1,2,3,4,5,6] # Download of whole dataset
  35. download(dataset_to_download)
  36. print('\n============= Download finished ==================\n\n')
  37. # List up 'dataset/' directory
  38. print('\n2=== List of available files in google drive ====\n')
  39. print(listdir('%sdataset/'%dir_origin))
  40. print('\n============= End of the list ==================\n\n')
  41. # List up dataset/rawdata/*.set and ~/*.fdt files
  42. print('\n3=== List of available files in google drive ====\n')
  43. print(listdir('%sdataset/rawdata/'%dir_origin))
  44. print('\n============= End of the list ==================\n\n')
  45. # Install mne-python module
  46. #system('pip install mne');