def main(): url_TEM_model = "https://osf.io/2hcfv/?action=download&version=4" # URL of TEM model hosted on OSF storage with the appropriate versioning on OSF url_SEM_model = "https://osf.io/sv7u2/?action=download&version=4" # URL of SEM model hosted on OSF storage with the appropriate versioning on OSF if ( not download_data(url_TEM_model) and not download_data(url_SEM_model) ) == 1: print("Data downloaded and unzipped succesfully.") else: print( "ERROR: Data was not succesfully downloaded and unzipped- please check your link and filename and try again." ) shutil.move("default_SEM_model", "AxonDeepSeg/models/default_SEM_model") shutil.move("default_TEM_model", "AxonDeepSeg/models/default_TEM_model")
def test_split_data_outputs_expected_number_of_folders(self): url_example_data = "https://osf.io/vrdpe/?action=download" # URL of example data hosted on OSF file_data = "SEM_dataset.zip" if not download_data(url_example_data) == 0: print( 'ERROR: Data was not succesfully downloaded and unzipped - please check your link and filename and try again.' ) else: print('Data downloaded and unzipped succesfully.') split_data(self.downloaded_data, self.data_split_path, seed=2019, split=[0.8, 0.2]) train_dir = self.data_split_path / "Train" valid_dir = self.data_split_path / "Validation" # get sorted list of train/validation directories train_subdirs = sorted([x for x in train_dir.iterdir() if x.is_dir()]) valid_subdirs = sorted([x for x in valid_dir.iterdir() if x.is_dir()]) assert len(train_subdirs) == 7 assert len(valid_subdirs) == 2
def test_split_data_throws_error_for_existing_folder(self): url_example_data = "https://osf.io/vrdpe/?action=download" # URL of example data hosted on OSF file_data = "SEM_dataset.zip" if not download_data(url_example_data) == 0: print( 'ERROR: Data was not succesfully downloaded and unzipped - please check your link and filename and try again.' ) else: print('Data downloaded and unzipped succesfully.') assert self.data_split_path.is_dir() with pytest.raises(IOError): split_data(self.downloaded_data, self.data_split_path, seed=2019, split=[0.8, 0.2])
def test_split_data_works_with_override(self): url_example_data = "https://osf.io/vrdpe/?action=download" # URL of example data hosted on OSF file_data = "SEM_dataset.zip" if not download_data(url_example_data) == 0: print( 'ERROR: Data was not succesfully downloaded and unzipped - please check your link and filename and try again.' ) else: print('Data downloaded and unzipped succesfully.') assert self.data_split_path.is_dir() split_data(self.downloaded_data, self.data_split_path, seed=2019, split=[0.8, 0.2], override=True) assert self.data_split_path.is_dir()
def test_download_data_returns_1_for_invalid_link(self): exit_code = download_data(self.bad_osf_link) assert exit_code == 1
def test_download_data_returns_0_for_valid_link(self): exit_code = download_data(self.osf_link) assert exit_code == 0