Sourcery refactored master branch - #3
Conversation
c49784b to
b0c868b
Compare
b0c868b to
872c410
Compare
| from highresnet import HighRes2DNet | ||
| model = HighRes2DNet(*args, **kwargs) | ||
| return model | ||
| return HighRes2DNet(*args, **kwargs) |
There was a problem hiding this comment.
Function highres2dnet refactored with the following changes:
- Inline variable that is only used once
| masked_img = ma.masked_array(img, np.logical_not(mask)).compressed() | ||
| perc_results = np.percentile(masked_img, 100 * np.array(perc)) | ||
| return perc_results | ||
| return np.percentile(masked_img, 100 * np.array(perc)) |
There was a problem hiding this comment.
Function __compute_percentiles refactored with the following changes:
- Inline variable that is only used once
| print(f'Detected spacing: {spacing}. Resampling to 1 mm iso...') | ||
| needs_resampling = not is_ras or not is_1_iso | ||
| return needs_resampling | ||
| return not is_ras or not is_1_iso |
There was a problem hiding this comment.
Function check_header refactored with the following changes:
- Inline variable that is only used once
| model = torch.hub.load(repo, model_name, pretrained=True) | ||
| return model | ||
| return torch.hub.load(repo, model_name, pretrained=True) |
There was a problem hiding this comment.
Function get_model refactored with the following changes:
- Inline variable that is only used once
| sitk.WriteImage(resampled, temp_path) | ||
| nifti_resampled = nib.load(temp_path) | ||
| return nifti_resampled | ||
| return nib.load(temp_path) |
There was a problem hiding this comment.
Function resample_spacing refactored with the following changes:
- Inline variable that is only used once
| nii_resampled = resample_spacing( | ||
| nii_ras, | ||
| output_spacing=one_iso, | ||
| interpolation=interpolation, | ||
| ) | ||
| return nii_resampled | ||
| return resample_spacing( | ||
| nii_ras, | ||
| output_spacing=one_iso, | ||
| interpolation=interpolation, | ||
| ) |
There was a problem hiding this comment.
Function resample_ras_1mm_iso refactored with the following changes:
- Inline variable that is only used once
| sample = dict( | ||
| image=window, | ||
| location=location, | ||
| ) | ||
| return sample | ||
| return dict( | ||
| image=window, | ||
| location=location, | ||
| ) |
There was a problem hiding this comment.
Function GridSampler.__getitem__ refactored with the following changes:
- Inline variable that is only used once
| input_output_diff = (3 - 1) + torch.sum(B * N * 2 ** (d + 1)) | ||
| receptive_field = input_output_diff + 1 | ||
| return receptive_field | ||
| return input_output_diff + 1 |
There was a problem hiding this comment.
Function HighResNet.receptive_field refactored with the following changes:
- Inline variable that is only used once
| if self.change_dimension: | ||
| if residual_type == 'project': | ||
| conv_class = nn.Conv2d if dimensions == 2 else nn.Conv3d | ||
| self.change_dim_layer = conv_class( | ||
| in_channels, | ||
| out_channels, | ||
| kernel_size=1, | ||
| dilation=dilation, | ||
| bias=False, # as in NiftyNet and PyTorch's ResNet model | ||
| ) | ||
| if self.change_dimension and residual_type == 'project': | ||
| conv_class = nn.Conv2d if dimensions == 2 else nn.Conv3d | ||
| self.change_dim_layer = conv_class( | ||
| in_channels, | ||
| out_channels, | ||
| kernel_size=1, | ||
| dilation=dilation, | ||
| bias=False, # as in NiftyNet and PyTorch's ResNet model | ||
| ) |
There was a problem hiding this comment.
Function ResidualBlock.__init__ refactored with the following changes:
- Merge nested if conditions
| config.read_string(config_string) | ||
| data_url = config['data']['url'] | ||
| return data_url | ||
| return config['data']['url'] |
There was a problem hiding this comment.
Function get_data_url_from_model_zoo refactored with the following changes:
- Inline variable that is only used once
Branch
masterrefactored by Sourcery.If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.
See our documentation here.
Run Sourcery locally
Reduce the feedback loop during development by using the Sourcery editor plugin:
Review changes via command line
To manually merge these changes, make sure you're on the
masterbranch, then run: